function check() {
//	bordercheck();
	rotatecheck();
	showShadowOptions();
	checkStuff();
	checkbg();
}

function rotatecheck() {


        for (i=0;i<document.form1.rotatechoice.length;i++) {
                if (document.form1.rotatechoice[i].checked) {

                        user_input = document.form1.rotatechoice[i].value;

                }
        }

	if (user_input == "yes") {
	
		document.getElementById("showrotate").style.display = '';
	
	} else {

		document.getElementById("showrotate").style.display = 'none';

	}

}

function bordercheck(time) {

	var animate_type;

        for (i=0;i<document.form1.borderselect.length;i++) {
                if (document.form1.borderselect[i].checked) {

                        user_input = document.form1.borderselect[i].value;

                }
        }

        for (i=0;i<document.form1.animatetype.length;i++) {
                if (document.form1.animatetype[i].checked) {
                        animate_type = document.form1.animatetype[i].value;
		}
        }

	if (animate_type == undefined) {


		alert("Please go back to step 1 and chose the type of glitter you want."); 
		document.forms['form1'].elements['borderselect'][1].checked = true;

	} else {

	if (user_input == "yes") {
		if (animate_type == "border") {
			document.getElementById("borderplacement").style.display = '';
		} else {
			document.getElementById("borderplacement").style.display = 'none';
		}

		document.getElementById("borderoptioncolor").style.display = '';
		document.getElementById("borderoptionsize").style.display = '';

	} else {

		document.getElementById("borderplacement").style.display  = 'none';
                document.getElementById("borderoptioncolor").style.display = 'none';
                document.getElementById("borderoptionsize").style.display = 'none';

	}

	}

}


function showShadowOptions() {

        for (i=0;i<document.form1.shadow.length;i++) {
                if (document.form1.shadow[i].checked) {

                        user_input = document.form1.shadow[i].value;

                }
        }

        for (i=0;i<document.form1.animatetype.length;i++) {
                if (document.form1.animatetype[i].checked) {

                        type_check = document.form1.animatetype[i].value;

                }
        }

	
	if (user_input == "yes") {

		document.getElementById("shadowoptions").style.display = '';

	} else {
		
		document.getElementById("shadowoptions").style.display = 'none';

	}

}

function checkStuff() {

	for (i=0;i<document.form1.animatetype.length;i++) {
        	if (document.form1.animatetype[i].checked) {

                	user_input = document.form1.animatetype[i].value;

	        }
	}


        for (i=0;i<document.form1.borderselect.length;i++) {
                if (document.form1.borderselect[i].checked) {

                        border_check = document.form1.borderselect[i].value;

                }
        }


	if (user_input == "border") {

		if (border_check == "yes") {
			
			document.getElementById("borderplacement").style.display = '';
        	        document.getElementById("borderoptioncolor").style.display = '';
	                document.getElementById("borderoptionsize").style.display = '';
			

		}

		document.getElementById("glitterborder").style.display = '';
        	document.getElementById("textcolor").style.display = '';


	} else {

		if (border_check == "yes") {
			document.getElementById("borderplacement").style.display = 'none';
                        document.getElementById("borderoptioncolor").style.display = '';
                        document.getElementById("borderoptionsize").style.display = '';


		}

                document.getElementById("glitterborder").style.display = 'none';
                document.getElementById("textcolor").style.display = 'none';


	}

	hidecode();

}


function ValidateForm(FormAction,FormTarget) {

        var user_input;


        for (i=0;i<document.form1.animatetype.length;i++) {
                if (document.form1.animatetype[i].checked) {

                        user_input = document.form1.animatetype[i].value;

                }
        }


        if (user_input == undefined) {
		alert("Please go back to step 1 and pick which type of image you would like.");
		return false;
	}

	if (document.form1.text.value == "") {
		alert("Whoops, looks like you forgot to enter the text you want!");
		return false;
	}

	if (document.form1.textcolor.value == "" && user_input == "border") {
		alert("Please select a text color in step number 2!");
		return false;
	}


	if (document.form1.font.value == "") {
		alert("Please go back to step 3 and select a font.");
		return false;
	}

        if (document.form1.glitter.value == "") {

                alert('Please go back to step 4 and select a glitter.');
                return false;

        } else {
                document.form1.action=FormAction;
                document.form1.target=FormTarget;
                document.form1.submit();
                document.getElementById('codebutton').style.display='';
        }

}


function hidecode() {
	document.getElementById("codebutton").style.display='none';
}

function checkbg() {
        for (i=0;i<document.form1.background.length;i++) {
                if (document.form1.background[i].checked) {

                        user_input = document.form1.background[i].value;

                }
        }

	if (user_input == "yes") {
		document.getElementById("backgroundselectbox").style.display = '';
		document.getElementById("selectedbackground").style.display = '';
		document.getElementById("showtiles").style.display = '';
		document.getElementById("showbackground").style.display = '';
	}

	if (user_input == "no") {
		document.getElementById("backgroundselectbox").style.display = 'none';
		document.getElementById("selectedbackground").style.display = 'none';
		document.getElementById("showtiles").style.display = 'none';
		document.getElementById("showbackground").style.display = 'none';
	}


}

function changebg(what) {
	    value = what.options[what.selectedIndex].value;
	    if (value != '') {
        	if (document.images) {
	            document.images['bgtile'].src = 'bgs/'+value;
		}
	    }
}

function bePatient() {
	document.getElementById("showpatient").style.display = '';
}
