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 openNewWindow(file,width,height)
{
	var newwindow = open(file,"","width=" + width + ",height=" + height + ",taskbar=no, scrollbars=yes, menubar=no,left=200,top=200,screenX=0,screenY=0", "");
	if (!newwindow)
	{
		alert("Sorry, this window failed to open, make sure you haven't a pop-up blocker installed, and your Javascript settings are set correctly.");
	}
	newwindow.document.close();
}

isIE = document.all;

function GoIfNotPosted(){		
	if (Posted == "False")
	{
	Go();
	}
}

function Go(){
       var theform;		
		if (isIE) {
			theform = document.forms[0];
			theform.submit();
		}
		else {
		    document.forms[0].submit();
		}
	}
	
function Show(ToShow)
{
	var O1 = document.getElementById(ToShow);
    O1.style.display = '';  
    
    O1.style.left = mouseX;
    O1.style.top = mouseY - O1.offsetHeight;
}
	
function ShowCode(ToShow)
{
    Hide(ToShow + "BTN");
	Show(ToShow);
}



function ShowAboveLeft(ToShow)
{
	var O1 = document.getElementById(ToShow);
    O1.style.display = '';  
    
    O1.style.left = mouseX - O1.offsetWidth - 5;
    O1.style.top = mouseY - O1.offsetHeight - 5;
}

function ShowTop(ToShow)
{
	var O1 = document.getElementById(ToShow);
    O1.style.display = '';      
    O1.style.left = 50 + "px";
    O1.style.top = (50 + document.body.scrollTop) + "px";
}
     
      
function Hide(ToShow)
{
	var O1 = document.getElementById(ToShow);
	O1.style.display = 'none';			
}

function SendData()
{
	var O1 = document.getElementById('PID');
	var O2 = document.getElementById('YourName');
	var O3 = document.getElementById('YourEmail');
	var O4 = document.getElementById('FriendsName');
	var O5 = document.getElementById('FriendsEmail');
	var O6 = document.getElementById('Message');
	var URL = "/SendData.aspx?PID=" + URLEncode(O1.value) + 
	"&YourName=" + URLEncode(O2.value) + 
	"&YourEmail=" + URLEncode(O3.value) +
	"&FriendsName=" + URLEncode(O4.value) +
	"&FriendsEmail=" + URLEncode(O5.value) +
	"&Message=" + URLEncode(O6.value);
	AJAXFetch(URL);
	alert("Thankyou. Your message has been sent");
	Hide("EmailToFriendDiv");	
}

function Go1st()
{

}

function SetAsViewed()
{
	var O1 = document.getElementById('PID');
	var O2 = document.getElementById('User');
	var URL = "/SendData.aspx?SetAsViewed=True" + 
	"&PID=" + URLEncode(O1.value) +
	"&User=" + URLEncode(O2.value);
	//alert(URL);
	AJAXFetch(URL);
}

function getMouseXY(e)
{ 
  if (!e) e = window.event;
  if (e)
  { 
      mouseX = isIE ? (e.clientX + document.body.scrollLeft) : e.pageX;
      mouseY = isIE ? (e.clientY + document.body.scrollTop) : e.pageY;
  }
}
document.onmousemove = getMouseXY;


function getSubStock(ParentID)
{ 
    AJAXFetchIntoDiv("/includes/ShowSubStock.aspx?Parent=" + ParentID, "Step1", false);	
}

function CheckSizes(Size)
{
    var SBForm = document.getElementById('SBForm');
    var radioLength = SBForm.length;
   	        	
	for(var i = 0; i < SBForm.length; i++) {
	
	    if (SBForm[i].name == "TheLength")
	    {
	        var theValue = SBForm[i].value;
	        
	        var O1 = document.getElementById(Size + " > " + theValue);
    		
		    if (O1) // Stock Size Exists
		    {
    		    SBForm[i].disabled = false;
		        SBForm[i].className = '';
		    }
		    else  // Stock Size Doesnt Exists
		    {		
		        SBForm[i].disabled = true;
		        SBForm[i].className = 'NoStockBox';
		    }
	    }	
	}
}

function SelectLength(theSID)
{
    var O1ID = "";
   
    for(var i = 0; i < SBForm.length; i++) {
	
	    if (SBForm[i].checked)
	    {
	        if (O1ID == "") O1ID =  SBForm[i].value + " > "
	        else O1ID += SBForm[i].value;   
	    }
	}
	
	var O1 = document.getElementById(O1ID);
   
    if (O1) // Stock Size Exists
	{
         var SID = document.getElementById("SID");
        SID.value = O1.value;
	} 		
}

