// Modal Dialog Box
// copyright 8th July 2006 by Stephen Chapman
// http://javascript.about.com/
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function pageWidth()
{
	return window.innerWidth != null? 
	window.innerWidth: 
	document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:
	null;
	}
function pageHeight() 
{
	return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}
function posLeft() 
{
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
}
function posTop() 
{
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
}
function $(x)
{
	return document.getElementById(x);
}
function scrollFix()
{
	var obol=$('ol');
	obol.style.top=posTop()+'px';
	obol.style.left=posLeft()+'px'
}
function sizeFix()
{
	var obol=$('ol');
	obol.style.height=pageHeight()+'px';obol.style.width=pageWidth()+'px';
}
function kp(e)
{
	ky=e?e.which:event.keyCode;
	if(ky==88||ky==120)hm();
	return false
}
function inf(h)
{
	tag=document.getElementsByTagName('select');
	for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('iframe');
	for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('object');
	for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;
}
function sm(obl, wd, ht)
{
	grayOut(true, {'opacity':'50'});
	var h='hidden';
	var b='block';
	var p='px';
	var obol=$('ol');
	var obbxd = $('mbd');
	obbxd.innerHTML = $(obl).innerHTML;
	obol.style.height=pageHeight()+p;
	obol.style.width=pageWidth()+p;obol.style.top=posTop()+p;
	obol.style.left=posLeft()+p;obol.style.display=b;var tp=posTop()+((pageHeight()-ht)/2)-12;
	var lt=posLeft()+((pageWidth()-wd)/2)-12;
	var obbx=$('mbox');obbx.style.top=(tp<0?0:tp)+p;obbx.style.left=(lt<0?0:lt)+p;obbx.style.width=wd+p;obbx.style.height=ht+p;inf(h);
	obbx.style.display=b;
	return false;
}



function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         	 alert('Please enter a valid quantity')
		 IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function hm(obl, sku)
{
 var passName =  document.getElementById("txtName").value;
 var passEmail =  document.getElementById("txtEmail").value;
 var passQuantity =  document.getElementById("txtQuantity").value;
 var pId = document.getElementById("txtprdId").value;
 var catId = document.getElementById("txtCat").value;
 if(echeck(passEmail)== false)
 {
	 return false;
 }
 if (passName == '')
 {
	 alert('Please enter your name')
	 return false;
 }
 if(IsNumeric(passQuantity) == false)
 {
	 return false;
 }
 grayOut(false, {'opacity':'25'});
 var v='visible';
 var n='none';
 $('ol').style.display=n;
 $('mbox').style.display=n;
 inf(v);
 if (sku == '')
 {
 window.location  = "stockAlertSignUp.asp?idproduct="+pId+"&idcategory="+catId+"&prdsku="+SelectedSku+"&sizeid="+SelectedSP+"&email="+passEmail+"&name="+passName+"&qty="+passQuantity;
 }
 else
 {
 window.location  = "stockAlertSignUp.asp?idproduct="+pId+"&idcategory="+catId+"&prdsku="+sku+"&email="+passEmail+"&name="+passName+"&qty="+passQuantity;
 }
}

function updateBox2(obl)
{
	var obol=$('ol');
	var obbxd = $('mbd');
	obbxd.innerHTML = $(obl).innerHTML;
	obbxd.getElementsByTagName("input")[1].value = obbxd.getElementsByTagName("input")[0].value
	alert(obbxd.getElementsByTagName("input")[0].value);

}
function cm()
{
	grayOut(false, {'opacity':'25'});
	var v='visible';
	var n='none';
	$('ol').style.display=n;
	$('mbox').style.display=n;
	inf(v);
}
function initmb()
{
	var ab='absolute';
	var n='none';
	var obody=document.getElementsByTagName('body')[0];
	var frag=document.createDocumentFragment();
	var obol=document.createElement('div');
	obol.setAttribute('id','ol');
	obol.style.display=n;
	obol.style.position=ab;
	obol.style.top=0;
	obol.style.left=0;
	obol.style.zIndex=998;
	obol.style.width='100%';
	frag.appendChild(obol);
	var obbx=document.createElement('div');
	obbx.setAttribute('id','mbox');
	obbx.style.display=n;
	obbx.style.position=ab;
	obbx.style.zIndex=999;
	var obl=document.createElement('span');
	obbx.appendChild(obl);
	var obbxd=document.createElement('div');
	obbxd.setAttribute('id','mbd');
	obl.appendChild(obbxd);
	frag.insertBefore(obbx,obol.nextSibling);
	obody.insertBefore(frag,obody.firstChild);
window.onscroll = scrollFix; 
window.onresize = sizeFix;
}
window.onload = initmb;

var qs = new Querystring()
function Querystring()
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);
// parse out name/value pairs separated via &
	var args = querystring.split('&');
// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');
		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		name = temp.join(' ');
		temp = unescape(pair[1]).split('+');
		value = temp.join(' ');
		this[name]=value;
	}
	this.get=Querystring_get;
}

function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}
	return value;
}

                  