// JavaScript Document
function get_url_param(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS ); 
	var results = regex.exec( window.location.href ); 
	if( results == null ) return "";
	else return results[1];
}

function returnAttributes(at){
	var arr=[];
	var elem=document.getElementsByTagName('td'), i=0, e;
	while(e=elem[i++]){
		e[at]?arr[arr.length]=e[at]:null;
	}
	return arr;
}

function getPageName() {
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	var allIds=returnAttributes('id'),ii;

	for(ii=0; ii<=allIds.length-1; ii++){
		if (allIds[ii].indexOf('current')==0){
                document.getElementById(allIds[ii]).id = allIds[ii].replace('current','');
         }
	}

	if (sPage == "default.asp" || sPage=='') {
			document.getElementById('home_nav').id = 'currenthome_nav';
			setInterval("nextSlide()",gSlideshowInterval * 1000); 
			//$(document).ready(function(){tb_show("Reminder","/v/vspfiles/demo/Reminder.html?height=200&width=400","/v/vspfiles/demo/images/monroe/big2.jpg");});  
    }

	if (sPage == "articles.asp") {
		var myvalue = get_url_param('id');
		if (myvalue =='161' || myvalue =='165' || myvalue =='169' || myvalue =='171' || myvalue =='172' || myvalue =='173' || myvalue =='174' || myvalue =='175' || myvalue =='201' || myvalue =='202' || myvalue =='203' || myvalue =='204'){
			document.getElementById('second_nav').id = 'currentsecond_nav';
		} 
		if (myvalue =='162' || (parseInt(myvalue) >= 176 && parseInt(myvalue) <= 199)){document.getElementById('third_nav').id = 'currentthird_nav';} 
		if (myvalue =='163'){document.getElementById('fourth_nav').id = 'currentfourth_nav';} 
	}

	 if (sPage == "SearchResults.asp") {
		var myvalue = get_url_param('Cat');
		if (myvalue =='3'){document.getElementById('fifth_nav').id = 'currentfifth_nav';} 
	}       
	
	if (sPage == "aboutus.asp") {
                document.getElementById('seventh_nav').id = 'currentseventh_nav';             
        }

	if (sPage == "mailinglist_subscribe.asp") {
                document.getElementById('sixth_nav').id = 'currentsixth_nav';             
        }
}
function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
	  retValue = retValue.substring(1, retValue.length);
	  ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
	  retValue = retValue.substring(0, retValue.length-1);
	  ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // trim for multiple spaces within the string
	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
   }
   return retValue; 
}
function ValidateForm(){
	//Check fields if there is an input
	if (trim(document.frm.comboval.value) == ""){
    	         alert("Please select the size of the shoe.");document.frm.comboval.focus();return false;
        }else if (trim(document.frm.rishlabelcont.value) == ""){
                 alert("Please enter the Baby's name to be printed on the right shoe.");document.frm.rishlabelcont.focus();return false;
	}
	
	
	for (var i=0; i < document.frm.leshlabelcontflag.length; i++){
		if (document.frm.leshlabelcontflag[i].checked){var radVal = document.frm.leshlabelcontflag[i].value;}
   	}
	
	if (radVal == 0){	//Date was chosen
		if (trim(document.frm.Month.value) == "0"){
			alert("Please select month.");document.frm.Month.focus();return false;
		}else if (trim(document.frm.Day.value) == "0"){
			alert("Please select day.");document.frm.Day.focus();return false;
		}else if (trim(document.frm.Year.value) == "0"){
			alert("Please select year.");document.frm.Year.focus();return false;
		}
	}else if (radVal == 1){ //Message was chosen
		if (trim(document.frm.Message.value) == ""){alert("Please enter message.");document.frm.Message.focus();return false;}           
        }
        
	if (radVal  == 0){	//Date was chosen		
	   document.frm.leshlabelcont.value = trim(document.frm.Month.value) + ' ' + trim(document.frm.Day.value) + ', ' + trim(document.frm.Year.value);
	}else if (radVal  == 1){ //Message was chosen
	    document.frm.leshlabelcont.value = trim(document.frm.Message.value);
	}
		
        if (document.frm.Yes.checked==true){return true;}else{alert('Please check the box if you approve the personalization.');document.frm.Yes.focus();return false;}
}
function SwapThumbnailImage(imgLocation){
	imgLocation = '/v/vspfiles/demo/images/' + imgLocation;
	document.getElementById("mainImage").src = imgLocation;
        document.getElementById("linkLargeImage").setAttribute('href', imgLocation); 
}
function EnableDisable(temp){
	if (temp=="bday"){
		document.frm.Message.disabled=true;
		document.frm.Month.disabled=false;
		document.frm.Day.disabled=false;
		document.frm.Year.disabled=false;
	}else{
		document.frm.Message.disabled=false;
		document.frm.Month.disabled=true;
		document.frm.Day.disabled=true;
		document.frm.Year.disabled=true;
	}
}
// JavaScript Document
function SetImageShoesStraps(){
	var imgLocation;
	
	for (var i=0; i < document.frm.shoes.length; i++){
		if (document.frm.shoes[i].checked){var shoesVal = document.frm.shoes[i].value;}
   	}
	
	for (var i=0; i < document.frm.straps.length; i++){
		if (document.frm.straps[i].checked){var strapsVal = document.frm.straps[i].value;}
   	}
	
	imgLocation = shoesVal + '_' + strapsVal + '.jpg';
	
	if (shoesVal=="monro"){
		imgLocation = '/v/vspfiles/demo/images/monroe-straps/' + imgLocation;
	}else{
		imgLocation = '/v/vspfiles/demo/images/pink-straps/' + imgLocation;
	}
	document.getElementById("bigShoeStrapImage").src = imgLocation;	
}
function personalize(){
	for (var i=0; i < document.frm.shoes.length; i++){
		if (document.frm.shoes[i].checked){var shoesVal = document.frm.shoes[i].value;}
	}
	
	for (var i=0; i < document.frm.straps.length; i++){
		if (document.frm.straps[i].checked){var strapsVal = document.frm.straps[i].value;}
   	}

	if (shoesVal=="monro"){
		if (strapsVal=="jan"){window.location.href="/articles.asp?id=176";}
		if (strapsVal=="feb"){window.location.href="/articles.asp?id=177";}
		if (strapsVal=="mar"){window.location.href="/articles.asp?id=178";}
		if (strapsVal=="apr"){window.location.href="/articles.asp?id=179";}
		if (strapsVal=="may"){window.location.href="/articles.asp?id=180";}
		if (strapsVal=="jun"){window.location.href="/articles.asp?id=181";}
		if (strapsVal=="jul"){window.location.href="/articles.asp?id=182";}
		if (strapsVal=="aug"){window.location.href="/articles.asp?id=183";}
		if (strapsVal=="sep"){window.location.href="/articles.asp?id=184";}
		if (strapsVal=="oct"){window.location.href="/articles.asp?id=185";}
		if (strapsVal=="nov"){window.location.href="/articles.asp?id=186";}
		if (strapsVal=="dec"){window.location.href="/articles.asp?id=187";}
	}else{
		if (strapsVal=="jan"){window.location.href="/articles.asp?id=188";}
		if (strapsVal=="feb"){window.location.href="/articles.asp?id=189";}
		if (strapsVal=="mar"){window.location.href="/articles.asp?id=190";}
		if (strapsVal=="apr"){window.location.href="/articles.asp?id=191";}
		if (strapsVal=="may"){window.location.href="/articles.asp?id=192";}
		if (strapsVal=="jun"){window.location.href="/articles.asp?id=193";}
		if (strapsVal=="jul"){window.location.href="/articles.asp?id=194";}
		if (strapsVal=="aug"){window.location.href="/articles.asp?id=195";}
		if (strapsVal=="sep"){window.location.href="/articles.asp?id=196";}
		if (strapsVal=="oct"){window.location.href="/articles.asp?id=197";}
		if (strapsVal=="nov"){window.location.href="/articles.asp?id=198";}
		if (strapsVal=="dec"){window.location.href="/articles.asp?id=199";}
	}
}

function CheckPrice(shoePrice, strapPrice){
	var ii, strapCtr=0, shoeCtr=0, strapPriceFinal, shoePriceFinal, total;
	
	for(ii=0; ii<document.frm.straps.length;ii++){
		if 	(document.frm.straps[ii].checked==true){strapCtr = strapCtr + 1;}
	}
	
	//strapPriceFinal = eval(parseFloat(strapPrice)) * eval(strapCtr);
	
	switch(strapCtr){
		case 1: strapPriceFinal = 6.00;strapPriceFinalText = "6.00";break;
		case 2: strapPriceFinal = 10.00;strapPriceFinalText = "10.00";break;
		case 3: strapPriceFinal = 15.00;strapPriceFinalText = "15.00";break;
		case 4: strapPriceFinal = 20.00;strapPriceFinalText = "20.00";break;
		case 5: strapPriceFinal = 25.00;strapPriceFinalText = "25.00";break;
		case 6: strapPriceFinal = 24.00;strapPriceFinalText = "24.00";break;
		case 7: strapPriceFinal = 28.00;strapPriceFinalText = "28.00";break;
		case 8: strapPriceFinal = 32.00;strapPriceFinalText = "32.00";break;
		case 9: strapPriceFinal = 36.00;strapPriceFinalText = "36.00";break;
		case 10: strapPriceFinal = 40.00;strapPriceFinalText = "40.00";break;
		case 11: strapPriceFinal = 44.00;strapPriceFinalText = "44.00";break;
		case 12: strapPriceFinal = 36.00;strapPriceFinalText = "36.00";break;
		default: strapPriceFinal = 0.00;strapPriceFinalText = "0.00";break;
	}
	
	shoePriceFinal = eval(parseFloat(shoePrice)) * eval(document.frm.quantity.value);
	total = eval(parseFloat(strapPriceFinal).toFixed(2)) + eval(parseFloat(shoePriceFinal).toFixed(2));
	
	document.frm.strapPrice.value = strapPriceFinalText;
	document.frm.shoePrice.value = eval(parseFloat(shoePriceFinal).toFixed(2));
	document.frm.total.value = eval(parseFloat(total).toFixed(2));
}
