
  $(document).ready(function(){	   
	$(".content").hide();						 
	$("span h1").click(function(){
		if($(this).is(".active")) {
         $(this).toggleClass("active");
         $(this).parent().next(".content").slideToggle();
         return false;
		} else {
			$(".content:visible").slideUp("slow");
			$("h1.active").removeClass("active"); 
			$(this).toggleClass("active");
			$(this).parent().next(".content").slideToggle();
			return false;
		}
	});
});

DD_roundies.addRule('.block', '8px');
DD_roundies.addRule('.block', '8px');
DD_roundies.addRule('.block', '8px', true);

function naveg(val){
	//alert(navigator.appName+' Version '+navigator.appVersion);
	isEight=navigator.appVersion.search('MSIE 8.0');
	//alert(isEight);
	if (navigator.appName == "Netscape")
	{
		return "textField"+val;
	}else{
		if(isEight>0){
			return "textField"+val;
		}else{
			val=val+1;
			return "textField"+val;
		}
	}
}

function fieldId(idRefer){
	isEight=navigator.appVersion.search('MSIE 8.0');
	if (navigator.appName == "Netscape")
	{
		return "textField"+idRefer;		
	}else{
		if(isEight>0){
			return "textField"+idRefer;
		}else{
			switch(idRefer){
				case 6:
					//alert(idRefer);
					idRes = "textField80";
					break;
				/*case 7:
					alert(idRefer);
					idRes = "textField89";
					break;*/
			}
			return idRes;
		}
	}
}

function finalStep(){
	finalchk=false;
	f3 = document.getElementById(naveg(3)); //Text
	f3Chk = document.getElementById('Text').checked; //Text
	
	f4 = document.getElementById(naveg(4)); //Birthday
	f4Chk = document.getElementById('Birthday').checked; //Birthday
	
	f6 = document.getElementById(fieldId(6)); //Font
	msg = document.getElementById('msgField'); //Text
	cot = document.getElementById('msgCnt'); //Div Container
	//f4Chk = document.getElementById('Birthdate').checked;
	
	f3.style.borderColor='#BDC2C9'; //Init Border Color
	f4.style.borderColor='#BDC2C9'; //Init Border Color
	f6.style.borderColor='#BDC2C9'; //Init Border Color
	
	if(f3Chk && f3.value==""){
		msgF3 = "<b>* You has selected Text option. Please fill the necessary field.</b><br />";
		//msg.innerHTML = "<b>You has selected Text option. Please fill the necessary field.</b>";
		//f3.style.borderColor='#FF0000';
		//cot.style.display='block';
		chk3 = false;
	}else{
		chk3 = true;
		msgF3 = "";
		if(!f3Chk){
			f3.value="None";
		}
	}
	if(f4Chk && f4.value==""){
		msgF4 = "<b>* You has selected Birthday option. Please fill the necessary field.</b><br />";
		//msg.innerHTML = "<b>You has selected Text option. Please fill the necessary field.</b>";
		//f3.style.borderColor='#FF0000';
		//cot.style.display='block';
		chk4 = false;
	}else{
		chk4 = true;
		msgF4 = "";
		if(!f4Chk){
			f4.value="None";
		}
	}
	if((f3Chk || f4Chk) && f6.value==""){
		msgF6 = "<b>* You has selected Text or Birthday or both. Please select the font style.</b><br />";
		//msg.innerHTML = "<b>You has selected Text option. Please fill the necessary field.</b>";
		//f3.style.borderColor='#FF0000';
		//cot.style.display='block';
		chk6 = false;
	}else{
		chk6 = true;
		msgF6 = "";
		if(!f3Chk){
			f6.value="None";
		}
	}
	
	if(!chk3 || !chk4 || !chk6){
		msgComplete = msgF3+msgF4+msgF6;
		if (!chk3)
			f3.style.borderColor='#FF0000';
		if (!chk4)
			f4.style.borderColor='#FF0000';
		if (!chk6)
			f6.style.borderColor='#FF0000';
		
		msg.innerHTML = msgComplete;
		cot.style.display='block';
	}
	
	if(chk3 && chk4 && chk6)
		finalchk = true;

	
	//if(f4Chk && f5Chk && f4.value=="" && f5.value==""){
	/*if(f3Chk && f3.value==""){
		msg.innerHTML = "<b>You has selected the text option. Please fill the necessary field.</b>";
		f4.style.borderColor='#FF0000';
		f5.style.borderColor='#FF0000';
		cot.style.display='block';
		chk4 = false; chk5 = false;		
	}else{
		if(f4Chk && f4.value==""){
			msg.innerHTML = "<b>You has selected Birthday option. Please fill the necessary field.</b>";
			f4.style.borderColor='#FF0000';
			cot.style.display='block';
			chk4 = false;
		}else{
			chk4 = true;
			if(!f4Chk){
				f4.value="None";
				if(!f5Chk)
					f7.value="None";
			}
		}*/
		
	
	
	
	if(finalchk){
		saveCustomization();	
	}else{
		alert('Please fill all your Customize Product fields.');
	}
};

function check(mival){
	
	var cadena=document.location.search; // Le quitamos el interrogante 
	var cadena1=document.location.pathname; // Le quitamos el interrogante 
	cadena=cadena.substring(1,cadena.length); // Separamos los distintos &
	cadena1=cadena1.substring(1,cadena1.length); // Separamos los distintos &
	//alert(cadena1);
	//if (cadena1 == "product.php"){
	if (cadena1.indexOf("product.php") >= 0){
		x1 = document.getElementById(naveg(0)); /*Top Fabric*/
		x2 = document.getElementById(naveg(1)); /*Bottom Fabric*/
		x3 = document.getElementById(naveg(2)); /*Design Embroidery*/
		x4 = document.getElementById(naveg(3)); /*Text*/
		x5 = document.getElementById(naveg(4)); /*Birthday*/
		x6 = document.getElementById(naveg(5)); /*Baby*/
		x7 = document.getElementById(fieldId(6)); /*Font*/
		//x8 = document.getElementById(fieldId(7)); /*MSG*/
		
		var params=cadena.split("=");
		
		if(params.length>1)
			var valos=params[1];
		if(valos==12){
			if (x1.value == "")
				x1.value = "Blue Flannel";			
			if (x2.value == "")
				x2.value = "Baby Boy Flannel";
			if (x3.value == "")
				x3.value = "None";
			if (x6.value == "")
				x6.value = "Unsure";
			if (x7.value == "")
				x7.value = "None";
			/*if (x8.value == "")
				x8.value = "None";*/
			x1.readOnly = true;
			x2.readOnly = true;
			x3.readOnly = true;
			x4.maxLength = 25;
			x5.maxLength = 18;
			x5.size = 18;
			x6.readOnly = true;
			x7.readOnly = true;
		}
		
		if (mival==1){				
			setTimeout("document.getElementById('buy_block2').submit()",500);
		}
	}
}

function gender(currObj){
	
	babyGender = document.getElementById('gender');
	
	gendSel = document.getElementById('group_12');
	
	switch(currObj){
		case 'Male':
			document.getElementById(naveg(5)).value = "Boy";			
			for (var opcombo=0;opcombo < gendSel.length;opcombo++){
    			if(gendSel.options[opcombo].text=="Boy"){ 
        			gendSel.selectedIndex=opcombo; 
					gendSel.onchange();
				} 
			}
			break;
		case 'Female':
			document.getElementById(naveg(5)).value = "Girl";
			for (var opcombo=0;opcombo < gendSel.length;opcombo++){
    			if(gendSel.options[opcombo].text=="Girl"){ 
        			gendSel.selectedIndex=opcombo; 
					gendSel.onchange();
				} 
			}
			break;
		case 'Unsure':
			document.getElementById(naveg(5)).value = "Unsure";
			for (var opcombo=0;opcombo < gendSel.length;opcombo++){
    			if(gendSel.options[opcombo].text=="Unsure"){ 
        			gendSel.selectedIndex=opcombo; 
					gendSel.onchange();
				} 
			}
			break;
	}
};

function repImgEasy(idDest,imgUrl,idSele,itemS){
	myObj = document.getElementById(idDest);
	myObj.src=imgUrl;
	//myObj.style.display = 'block';
	objChk = document.getElementById(idSele);
	
	for (var opcombo=0;opcombo < objChk.length;opcombo++){ 
    	if(objChk[opcombo].value==itemS){ 
        	objChk.selectedIndex=opcombo; 
		
			if (idDest=="picS1"){
				document.getElementById(naveg(0)).value = objChk.options[opcombo].text;
				document.getElementById('opt1').value = imgUrl;
			}
			if (idDest=="picS2"){
				document.getElementById(naveg(1)).value = objChk.options[opcombo].text;
				document.getElementById('opt2').value = imgUrl;
			}
		}
	}
	
};

function repImg(idDest,imgUrl,idSele,itemS){
	myObj = document.getElementById(idDest);
	myObj.src=imgUrl;
	document.getElementById('opt3').value=imgUrl;
	myObj.style.display = 'block';
	objChk = document.getElementById(idSele);
	
	document.getElementById('embnone').checked = false;

	for (var opcombo=0;opcombo < objChk.length;opcombo++){ 
    	if(objChk[opcombo].value==itemS){ 
        	objChk.selectedIndex=opcombo; 
			objChk.onchange();
			
			if (idDest=="picS3"){
				document.getElementById(naveg(2)).value = objChk.options[opcombo].text;
			}
		} 
	}
	
	
	
};

function repImgFnt(imgUrl,legend){
	
	obChk1 = document.getElementById('Text');
	obChk2 = document.getElementById('Birthday');
	
	if (obChk1.checked || obChk2.checked){
		//alert(imgUrl+' - '+legend);
		myObj = document.getElementById('picS4');
		myObj.src=imgUrl;
		document.getElementById('opt4').value=imgUrl;
		myObj.style.display = 'block';
		//document.getElementById(fieldId()).value = legend;
		document.getElementById(fieldId(6)).value = legend;
	}	
};


function chkNone(idDest,type){
	myObj = document.getElementById(idDest);
	myIm1 = document.getElementById('picS3');
	myIm2 = document.getElementById('picS4');
	var Emb = "Embroidery";
	var Txt = "Text";
	var Bdt = "Birthdate";
	obChk1 = document.getElementById(Txt);
	obChk2 = document.getElementById(Bdt);
	if (myObj.options[myObj.selectedIndex].text == "None"){
		if (type == Emb){
			myIm1.style.display = 'none';
			document.getElementById(naveg(2)).value = "None";
		}
		if (type == Txt){
			if (obChk1.checked){
				obChk1.checked = false;
				if (!obChk2.checked){
					myIm2.style.display = 'none';
					document.getElementById(fieldId()).value = "None";
				}
			}
		}
		if (type == Bdt){
			if (obChk2.checked){
				obChk2.checked = false;
				if (!obChk1.checked){
					myIm2.style.display = 'none';
					document.getElementById(fieldId()).value = "None";
				}
			}
		}
		
	}
};

function nonEmbroidery(){
	
	f2 = document.getElementById(naveg(2)); //Text	
	embySel = document.getElementById('group_6');
	myObj = document.getElementById('picS3');
	
	for (var opcombo=0;opcombo < embySel.length;opcombo++){
    	if(embySel.options[opcombo].text=="None"){ 
       		embySel.selectedIndex=opcombo; 
			embySel.onchange();
			f2.value = "None";			
			myObj.style.display = 'None';
			document.getElementById('opt3').value="";
		} 
	}
	
}

function verify(currObj){
	
	f5 = document.getElementById(fieldId(6)); //Font Selection
	chT = document.getElementById('Text').checked; /*Text*/
	chB = document.getElementById('Birthday').checked; /*Birthday*/
	
	if(!chT && !chB){
			f5.value = "None";
			myObj = document.getElementById('picS4');
			myObj.style.display = 'none';
			document.getElementById('opt4').value="";
		}
	
	switch(currObj.id){
		case "Birthday":
			textSel = document.getElementById('group_8'); //Birthday Selection
			fx = document.getElementById(naveg(4)); /*Birthday*/	
			break;
		case "Text":
			textSel = document.getElementById('group_9'); //Text Selection
			fx = document.getElementById(naveg(3)); /*Text*/
			break;
	}
	
	if (currObj.checked){
		for (var opcombo=0;opcombo < textSel.length;opcombo++){
    		if(textSel.options[opcombo].text=="Include"){ 
        		textSel.selectedIndex=opcombo; 
				textSel.onchange();
				if(f5.value=="None")
					f5.value = "";				
				fx.value = "";
			} 
		}

	}else{
		for (var opcombo=0;opcombo < textSel.length;opcombo++){
    		if(textSel.options[opcombo].text=="None"){ 
        		textSel.selectedIndex=opcombo; 
				textSel.onchange();				
			} 
		}
	}
};