function preload() {
    jQuery.preloadImages("/img/navi_1_on.gif", "/img/navi_2_on.gif", "/img/navi_3_on.gif", "/img/navi_4_on.gif", "/img/vis_gewinnspiel_intro.jpg", "/img/bg_vis_main_1_q1.jpg", "/img/bg_vis_main_1_q2.jpg", "/img/bg_vis_main_1_q3.jpg", "/img/bg_vis_main_1_q4.jpg", "/img/bg_vis_main_1_q5.jpg", "/img/bg_vis_gewinnspiel_ende.jpg", "/img/bg_vis_gewinnspiel_kontakt.jpg");
}

jQuery(function(){
    jQuery("img.rollover").hover(
		function(){
			this.src = this.src.replace("_off","_on");
		},
		function(){
			this.src = this.src.replace("_on","_off");
	    }
	);
})


$(document).ready(function() {
	$('#subnav1').mouseover(function() { $('#subnav1').attr({src: "img/nav_gewinnspiel_1_on.jpg"}); });
	$('#subnav1').mouseout(function() { $('#subnav1').attr({src: "img/nav_gewinnspiel_1_off.jpg"}); });
	$('#subnav2').mouseover(function() { $('#subnav2').attr({src: "img/ico_contact_callback_active.gif"}); });
	$('#subnav2').mouseout(function() { $('#subnav2').attr({src: "img/ico_contact_callback.gif"}); });
});

function switchForm(nr) {
	jQuery(".gewinnspiel").hide();
	jQuery("#gewinnspiel"+nr).show();
	jQuery("#winFalse").hide();
	jQuery("#gewinnspielHint").hide();
	jQuery(".winTrue").hide();
	jQuery(".winIndicator").hide();
};

function switchContactForm() {
	jQuery("#kontakt").hide();
	jQuery("#kontakt2").show();
};

function showGewinnspiel() {
	jQuery("#gewinnspiel1").show();
	jQuery("#gewinnspiel0").hide();
	jQuery("#gasTank").show();
}

function showPrivacy() {
	jQuery("#datenschutz").show();
	jQuery("#flashContent").hide();
	jQuery("#salutation").hide();
}

function hidePrivacy() {
	jQuery("#datenschutz").hide();
	jQuery("#flashContent").show();
	jQuery("#salutation").show();
}

function checkQuestion(no, step, answer) {
	if (step == 1 && answer == 1) {
		jQuery("#gewinnspielHint").hide();
		jQuery("#winFalse").hide();
		jQuery(".winTrue").show();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_1.gif");
		jQuery(".winIndicator").show();
		getMovie("flashContent").sound("2");
	} 
	else if (step == 2 && answer == 1) {
		jQuery("#gewinnspielHint").hide();	
		jQuery(".winTrue").show();
		jQuery("#winFalse").hide();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_2.gif");
		jQuery(".winIndicator").show();
		getMovie("flashContent").sound("2");
	}
	else if (step == 3 && answer == 1) {
		jQuery("#gewinnspielHint").hide();	
		jQuery(".winTrue").show();
		jQuery("#winFalse").hide();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_3.gif");
		jQuery(".winIndicator").show();
		getMovie("flashContent").sound("2");
	}
	else if (step == 4 && answer == 1) {
		jQuery("#gewinnspielHint").hide();	
		jQuery(".winTrue").show();
		jQuery("#winFalse").hide();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_4.gif");
		jQuery(".winIndicator").show();
		getMovie("flashContent").sound("2");
	}
	else if (step == 5 && answer == 1) {
		jQuery("#gewinnspielHint").hide();	
		jQuery(".winTrue").show();
		jQuery("#winFalse").hide();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_5.gif");
		jQuery(".winIndicator").show();
		getMovie("flashContent").sound("2");
	}
	else {
		jQuery("#gewinnspielHint").hide();	
		jQuery(".winTrue").hide();
		jQuery("#winFalse").show();
		jQuery("#gasTankImg").attr("src", "/img/vis_tank_"+no+".gif");
		jQuery(".winIndicator").hide();
		getMovie("flashContent").sound("1");
	}
}

function checkField(j,field_name) {
    if( eval('j.'+ field_name +'') == 1 ) {
        jQuery("#"+ field_name).addClass("labelerror");
    } else {
        jQuery("#"+ field_name).removeClass("labelerror");
	}
}

function getMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function checkStep(intStep) {
	if (intStep < 5) {
		if (jQuery(".winIndicator").is(":visible")) {
			if (jQuery("#gewinnspielHint").is(":visible")) {
				jQuery("#gewinnspielHint").hide();
			}
			switchForm(intStep + 1);
		} else {
			jQuery("#gewinnspielHint").hide();
			jQuery("#winFalse").show();
		}
	} else {
		if (jQuery(".winIndicator").is(":visible")) {
			location.href="gewinnspiel_danke.asp";
		}
	}
}
