// JavaScript Document
	$(document).ready(function(){
		$(".sf-menu")
			.superfish({
				animation : { opacity:"show",height:"show"},
				autoArrows : true,
				dropShadows : false
				
			}).css('opacity',0.95);
		
		$(".sf-menu li a").each( function(i) {
			if($(this).height()>40)$(this).css('line-height','20px');
		});
		

	});
	
// apply to all png images and to div#logo 
$('img[@src$=.png]').ifixpng(); 


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_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openLoginBox() {
 document.getElementById('loginbox').style.display = 'block';
 }
 
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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 MM_validateFormCheckout2() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormCheckout2.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); 
	} else {
		if(document.checkout.MultipleAddresses.checked == true) {
	  		document.checkout.action = './split_ship_saved.php';
		} else {
			document.checkout.action ='./checkout_3.php';
		}
	}
  	document.MM_returnValue = (errors == '');
}

function validateQuantity(field) { 
	var min = 1
	var max = 100
	if ( (parseInt(field.value) != field.value) || 
		field.value < min || field.value > max) { 
		alert('You must enter a quantity between 1 and 100'); 
		field.focus(); 
		field.select(); 
		return false; 
	} 
	return true; 
 }
 
function close_window() {
    window.close();
}

function warningwindow(sentUrl,message) {
	if (confirm(message)) {
	parent.location=(sentUrl)
	}
	else {
	}
}

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to delete this address?");
if (agree)
	return true ;
else
	return false ;
}

 function doblowup(title, image, description, width, height) {
    var win = open('Blow Up', '', "height=" + height + ",width=" + width + ",status=yes,scrollbars=yes,resizable=1,menubar=0");
    var html = '';
    html += '<html>';
    html += '<head>';
    html += '<title>Images</title>';
    html += '<link href="style.css" rel="stylesheet" rev="stylesheet" type="text/css"></head>';
    html += '<body bgcolor="#DCDDD6" TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 >';
    html += '<table align=center>';
    html += '<tr><td align="center"><a href="javascript:window.print();"><FONT size=2>PRINT PAGE</font></a></td></tr>';
    html += '<tr><td align="center"><img src="' + image + '" border="1" vspace="6"><br></td></tr>';
    html += '<tr><td align="center"></br>' + description + '</td></tr>';
    html += '<tr><td align="center"><a href="javascript:window.close();"><FONT size=2>CLOSE WINDOW</font></a></td></tr>';
    html += '</table></body></html>';
    win.document.open();
    win.document.write(html);
    win.document.close();
  }
  
function random_imglink(dir){
			var myimages = new Array()
			var iImageCnt = 8
			//specify random images below. You can have as many as you wish
			myimages[1]= "/graphics/skins/Slide1.jpg"		
			myimages[2]= "/graphics/skins/Slide2.jpg"		
			myimages[3]= "/graphics/skins/Slide3.jpg"		
			myimages[4]= "/graphics/skins/Slide4.jpg"		
			myimages[5]= "/graphics/skins/Slide5.jpg"		
			myimages[6]= "/graphics/skins/Slide6.jpg"
			myimages[7]= "/graphics/skins/Slide7.jpg"
			//myimages[8]= "/graphics/skins/Slide8.jpg" ASPENS/FISHEYE
			myimages[9]= "/graphics/skins/Slide9.jpg"
			
			
			//var ry = Math.floor(Math.random()* myimages.length)
			var ry = Math.floor(Math.random()* iImageCnt)
			if (ry==0)
			ry=1
			document.write('<img src="'+myimages[ry]+'"  width="587" height="130" border="0">')
		}
		
function clearValue(){
  	document.getElementById('Email').value='';
  }
