// JAVASCRIPT FUNCTIONS USED IN www.shoedeals4u.com 
//Danny 08/08/07

function RefreshPage(){
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}

function cancelAction (evt) {
  return false;
}
function disableSubmitButton (button) {
  if (typeof button.disabled != 'undefined')
    button.disabled = true;
  else if (!button.buttonDisabled) {
    button.oldValue = button.value;
    button.oldOnclick = button.onclick;
    button.value = 'DISABLED';
    button.onclick = cancelAction;
    button.buttonDisabled = true;
  }
}

function enableSubmitButton (button) {
  if (typeof button.disabled != 'undefined')
    button.disabled = false;
  else if (button.buttonDisabled) {
    button.value = button.oldValue;
    button.onclick = button.oldOnclick;
    button.buttonDisabled = false;
  }
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr);
}

function detail_onSubmit(){
   if(document.detail.size.value == -1)
    {   
      alert("Please select the size for the item !!!");
	  return false;
	 }
   if(document.detail.width.value == 100)
    {   
      alert("Please select the width for the item !!!");
	  return false;
	 }
	 return true;
} 	

function showsize(text,url){
 PageURL='notifysize1.asp?sku=<%=(r.Fields.Item("ShoeId").Value)%>&notsize=' + document.all["size"].value + "&notwidth=" + document.all["width"].value;
 WindowName='Notifymewithmysize'; 
 settings='toolbar=no,location=no,directories=no,'+'status=no,menubar=no,scrollbars=no,'+'resizable=yes,width=600,height=250';
 MyWindow=window.open(PageURL,WindowName,settings); 
}

function showemail(text,url){
 PageURL='../emailfriend.asp';
 WindowName='Sendemailtoafriend';
 settings='toolbar=no,location=no,directories=no,'+'status=no,menubar=no,scrollbars=no,'+'resizable=yes,width=600,height=420';
 MyNewWindow=window.open(PageURL,WindowName,settings); 
}

//display the picture larger
function showPhoto(pFileName,pTitle,pCaption){
   photoWin=window.open("","Shoe","width=600,height=600");
   photoWin.document.write('<html><head><title>'+pTitle+'</title></head>');
   photoWin.document.write('<body bgcolor=#ffffff text=#ffffcc>');
   photoWin.document.write('<font color="#003399" size="2" face="Arial, Helvetica, sans-serif">ShoeDeals4u.com</font>');
   photoWin.document.write('<BR>');
   photoWin.document.write('<center><img src="'+pFileName+'" width="500" height="500" ></center>');
   photoWin.document.write('<BR>');
   photoWin.document.write('<BR>');
   photoWin.document.write('<div align="right"><a href="javascript:window.close()">Close</a> </div>');
   photoWin.document.write('</body></html>');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function searchsku_onSubmit(){
  if(document.searchsku.sku.value == ''){
    alert("Pleaase insert a SKU number");
	return false;
  }
  return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkavailabletime(){
	if (!document.all["available"]) return;
    document.all["available"].value='';
   //document.all["notify"].value="";
    //document.all["notify"].className="notify";
	enableSubmitButton(document.detail.Submit2);
	
	var currdate=new Date();
	var availdate;
	
for (var i = 0; i < sizearray.length; i= i + 1){	
	if (availarray[i].length>0){
		availdate=Date.parse(availarray[i]);
	}
	else{
		availdate=Date.parse("1/1/1900");
	}
 	if (sizearray[i] == document.all["size"].value &&  widtharray[i] == document.all["width"].value && currdate<availdate)
		{
		document.all["available"].value='     This item is not available to ship until ' + availarray[i];   
		//document.all["notify"].value="Notify me when my size is available";
		// document.all["notify"].className="notifyhand";
		disableSubmitButton(document.detail.Submit2);
		 return true;
	  }
 }
 return true;
}