var theURL;
var thePAGE;
var xmlhttp;
var identity;
var identityAff;
var identityUpdate
//popup menu
sfHover = function() {
	try{
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}catch(e){
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover = function() {
	try{
	var sfEls = document.getElementById("nav1").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}catch(e){
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function fullWindow(url, windowname) 
   { 
   var str = "left=0,screenX=0,top=0,screenY=0,resizable,toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,";
   if (window.screen) 
      {
      var ah = screen.availHeight - 100;
      var aw = screen.availWidth - 100;
      str += ",height=" + ah;
      str += ",innerHeight=" + ah;
      str += ",width=" + aw;
      str += ",innerWidth=" + aw;
      }
   win=window.open(url, windowname, str);
   }
function popItUp(url){
	var StockInfoWin=window.open(url,"stockinfo","width=650,height=550,resizable=0,status=0,menubar=0,scrollbars=yes");
}
//------functions to update affiliate information------------
function UpdateValidateAffiliate( updatepage, control ){
	thePAGE = "accountmenu-affiliateupdate.asp?thepage="+updatepage;
	identityUpdate = document.getElementById( control );
	if(updatepage == 9){
		firstname = document.ContactForm.firstname.value
        lastname = document.ContactForm.lastname.value;
        address1 = document.ContactForm.address1.value;
        address2 = document.ContactForm.address2.value;
        city = document.ContactForm.city.value;
        state = document.ContactForm.state.value;
        zipcode = document.ContactForm.zipcode.value;
        country = document.ContactForm.affcountry.value;
        daytimephone = document.ContactForm.daytimephone.value;
        eveningphone = document.ContactForm.eveningphone.value;
		thePAGE = thePAGE+"&firstname="+firstname+"&lastname="+lastname+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&zipcode="+zipcode+"&country="+country+"&daytimephone="+daytimephone+"&eveningphone="+eveningphone
	}else if(updatepage == 10){
	affSiteName=document.ContactForm.sitename.value;
	affSiteURL=document.ContactForm.siteurl.value;
	affVisitors=document.ContactForm.visitors.value;
    affPageHits=document.ContactForm.pagehits.value;
    affDescription=document.ContactForm.description.value;
	affCatpfs=document.ContactForm.affCatpfs.checked;
	affCatgfs=document.ContactForm.affCatgfs.checked;
    affCatcol=document.ContactForm.affCatcol.checked;
    affCatgam=document.ContactForm.affCatgam.checked;
    affCatsho=document.ContactForm.affCatsho.checked;
    affCatfam=document.ContactForm.affCatfam.checked;
    affCatchi=document.ContactForm.affCatchi.checked;
    affCatedu=document.ContactForm.affCatedu.checked;
    affCatint=document.ContactForm.affCatint.checked;
    affCatcom=document.ContactForm.affCatcom.checked;
    affCatmed=document.ContactForm.affCatmed.checked;
    affCatpor=document.ContactForm.affCatpor.checked;
    affCatoth=document.ContactForm.affCatoth.checked;
    affCatother=document.ContactForm.affCatother.value;
	thePAGE = thePAGE+"&affCatother="+affCatother+"&affSiteName="+affSiteName+"&affSiteURL="+affSiteURL+"&affVisitors="+affVisitors+"&affpagehits="+affPageHits+"&affdescription="+affDescription+"&affcatpfs="+affCatpfs+"&affcatgfs="+affCatgfs+"&affCatcol="+affCatcol+"&affCatgam="+affCatgam+"&affcatsho="+affCatsho+"&affCatfam="+affCatfam+"&affCatchi="+affCatchi+"&affCatedu="+affCatedu+"&affCatint="+affCatint+"&affCatcom="+affCatcom+"&affCatmed="+affCatmed+"&affCatpor="+affCatpor+"&affCatoth="+affCatoth
	}else if(updatepage == 11){
        ptname=document.ContactForm.ptname.value
        ptaddress1=document.ContactForm.ptaddress1.value
        ptaddress2=document.ContactForm.ptaddress2.value
        ptcity=document.ContactForm.ptcity.value
        ptstate=document.ContactForm.ptstate.value
        ptzipcode=document.ContactForm.ptzipcode.value
        ptcountry=document.ContactForm.ptcountry.value
		thePAGE = thePAGE+"&ptname="+ptname+"&ptaddress1="+ptaddress1+"&ptaddress2="+ptaddress2+"&ptcity="+ptcity+"&ptstate="+ptstate+"&ptzipcode="+ptzipcode+"&ptcountry="+ptcountry
	}else{
	}
	getHTTPObjectUpdate();
	return false;
}
function getHTTPObjectUpdate(){
		if (window.XMLHttpRequest)
  		{
  			xmlhttp=new XMLHttpRequest();
  			xmlhttp.onreadystatechange=handleHttpResponse3;
  			xmlhttp.open("GET",thePAGE,true);
  			xmlhttp.send(null);
 		 }
		// code for IE
		else if (window.ActiveXObject)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    		if (xmlhttp){
    			xmlhttp.onreadystatechange=handleHttpResponse3;
			    xmlhttp.open("GET",thePAGE,true);
			    xmlhttp.send(null);
		    }
  		}
		return false;
}
function handleHttpResponse3() {
//alert(xmlhttp.readyState)
 if (xmlhttp.readyState == 4) {
    results = xmlhttp.responseText;
	if(results.length > 0){
	//alert(results);
	try{
		identityUpdate.innerHTML = results;
	}catch(e)	//IE pulling shenanigans.
	{
		var wrappingform = document.createElement('div'); 
		wrappingform.innerHTML = xmlhttp.responseText;
		identityUpdate.innerHTML = "";
		identityUpdate.appendChild(wrappingform);
	}
	}else{
		try{
		identityUpdate.innerHTML = '<font class="lgRedBold">ERROR PROCESSING REQUEST!</font>';
		}catch(e){
			alert("error");
		}
	}
  }else{
  }
  return false;
}
//----------------------------------------------------------
   function popItUpBMP(url) 
      {
      var StockInfoWin=window.open(url,"BMP","width=540,height=550,resizable=0,status=0,menubar=0,scrollbars=yes");
	  return false;
      }
//----loading report form information-----------------------

function loadReport( reportload, variatech ){
	//alert(variables);
	try{
	//alert("reportload: "+reportload+" variables: "+variatech);
		accountmenudisplay( reportload, 'reportaccount', variatech);
	}catch(e){
	//alert("issue with IE");
	}
	return false;
}
//---------accoutnment code here--------
function getHTTPObjectAff(){
		if (window.XMLHttpRequest)
  		{
  			xmlhttp=new XMLHttpRequest();
  			xmlhttp.onreadystatechange=handleHttpResponse2;
  			xmlhttp.open("GET",thePAGE,true);
  			xmlhttp.send(null);
 		 }
		// code for IE
		else if (window.ActiveXObject)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    		if (xmlhttp){
    			xmlhttp.onreadystatechange=handleHttpResponse2;
			    xmlhttp.open("GET",thePAGE,true);
			    xmlhttp.send(null);
		    }
  		}
		return false;
}
function handleHttpResponse2() {
//alert(xmlhttp.readyState)
 if (xmlhttp.readyState == 4) {
    results = xmlhttp.responseText;
	if(results.length > 0){
//	alert(results);
	try{
		identityAff.innerHTML = results;
	}catch(e)	//IE pulling shenanigans.
	{
		var wrappingform = document.createElement('div'); 
		wrappingform.innerHTML = xmlhttp.responseText;
		identityAff.innerHTML = "";
		identityAff.appendChild(wrappingform);
	}
	}else{
		identityAff.innerHTML = '<font class="lgRedBold">ERROR PROCESSING REQUEST!</font>';
	}
  }else{
 	identityAff.innerHTML = '<font class="lgbluebold">Compiling report.</font>';
  }
  return false;
}
function accountmenudisplay( theurlpage, spanid, variables){
	try{
	identityAff = document.getElementById( spanid );
	thePAGE = "accountmenu-affiliateguts.asp?thepage="+theurlpage+variables;
	//alert(thePAGE);
	getHTTPObjectAff();
	}catch(e){
	}
	return false;
}
//---------accoutnmenu code end here--------

function handleHttpResponse() {
 if (xmlhttp.readyState == 4) {
    results = xmlhttp.responseText;
	if(results.length > 0){
		identity.innerHTML = "When this item:";
		identity2 = document.getElementById( 'formerror' );
		if(!document.itemform.chinstock.checked && !document.itemform.chdesc.checked && !document.itemform.chimage.checked && !document.itemform.chdate.checked){
			identity2.innerHTML = '<font class="smredbold"><img src="images/sitewide/iconsmallalert.gif"> To create a Product Reminder, please check at least one criteria.</font>'	
		}else{
			identity2.innerHTML = ''
			document.itemform.insertemail.value='1';
			document.itemform.submit();
		}
		//valid stock number
		//document.itemform.submit();
	}else{
		identity.innerHTML = '<font class="smredbold"><img src="images/sitewide/iconsmallalert.gif"> When this item:</font>'
		identity2 = document.getElementById( 'formerror' );
		identity2.innerHTML = '<font class="smredbold"><img src="images/sitewide/iconsmallalert.gif"> To create a Item Reminder, please enter a valid item number.</font>'
	}
  }
  return false;
}
function ItemVerify( thestring, control ) {
	identity = document.getElementById( control );
	theURL = "verifyStockItem.asp?Search="+thestring;
	//alert(theURL);
	getHTTPObject();
	return false;
}
function getHTTPObject(){
	//alert("here");
	if (window.XMLHttpRequest)
  	{
  		xmlhttp=new XMLHttpRequest();
  		xmlhttp.onreadystatechange=handleHttpResponse;
  		xmlhttp.open("GET",theURL,true);
  		xmlhttp.send(null);
 	 }
	// code for IE
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") 
    	if (xmlhttp){
    		xmlhttp.onreadystatechange=handleHttpResponse;
		    xmlhttp.open("GET",theURL,true);
		    xmlhttp.send(null);
	    }
  	}
	return false;
}
function verifyDelete( id, control ){
	if( id%2 == 1 ){
		yesbutton = 'BT_yes_orange_blue.gif'
		nobutton = 'BT_no_white_blue.gif'
	}else{
		yesbutton = 'BT_yes_orange.gif'
		nobutton = 'BT_no_white.gif'
	}
	identity = document.getElementById( control );
	identity.innerHTML = '<input type="Hidden" name="deleteemail" value="1"><input type="Image" src="images/buttons/'+yesbutton+'" name="yes'+id+'" onclick="document.thisform'+id+'.thepage.value=\'1\'; document.thisform'+id+'.submit(); return false;"><input type="Image" src="images/buttons/'+nobutton+'" onclick="verifyno( \''+id+'\', \''+control+'\'); return false;" name="no'+id+'">';
	identity2 = document.getElementById( 'deleteconfirm'+id );
	identity2.innerHTML = '<table cellspacing="0" cellspacing="0" border="0"><tr><td class="SmRedBold"><img src="images/sitewide/iconsmallalert.gif"> Are you sure you want to delete this reminder?</td></tr></table>';
	//alert(identity2.innerHTML);
	/*if(thestring.match('^([0-9][0-9]|[0-9])/([0-3][0-9]|[0-9])/[0-9]{4}$')){
		identity.innerHTML = '<table cellpadding="0" cellspacing="0" border="0"><tr class="SmBlack"><td><b>Date: </b></td></tr></table>';
		validDate = 1;
		if(validTitle==1 && validDate==1 && validlength==1 && validdesc==1){
			document.thisform.cmdSubmit.disabled = false;
		}
	}else{
		identity.innerHTML = '<table cellpadding="0" cellspacing="0" border="0"><tr class="SmRedBold"><td>Date(DD/MM/YYYY):</td></tr></table>';	
		validDate = 0;
		document.thisform.cmdSubmit.disabled = true;
	}*/
	return false;
}

function verifyno( id, control ){
	if( id%2 == 1 ){
		editbutton = 'BT_edit_white_blue.gif'
		deletebutton = 'BT_delete_white_blue.gif'
	}else{
		editbutton = 'BT_edit_white.gif'
		deletebutton = 'BT_delete_white.gif'
	}
	identity = document.getElementById( control );
	//alert(control);
	identity.innerHTML = '<input onclick="document.thisform'+id+'.submit(); return false;" type="Image" src="images/buttons/'+editbutton+'" name="edit'+id+'" ><input type="Image" onclick="verifyDelete( \''+id+'\', \''+control+'\'); return false;" src="images/buttons/'+deletebutton+'" name="Delete'+id+'">';
	identity2 = document.getElementById( 'deleteconfirm'+id );
	identity2.innerHTML = '' 
	return false;
}

function youSure( control ){
	identity = document.getElementById( control );
	identity.innerHTML = '<table align="center"><tr><td class="smredbold" align="center"><img src="images/sitewide/iconsmallalert.gif"> Are you sure you want to delete this category reminder?</td></tr><tr><td align="center"><input type="Image" src="images/buttons/BT_yes_orange.gif" onclick="document.catform.deleteemail.value=\'1\'; document.catform.submit(); return false;"><input type="Image" src="images/buttons/BT_no_white.gif" onclick="notSure( \''+control+'\' );"></td></tr></table>';
	return false;
}

function youSure2( control ){
	identity = document.getElementById( control );
	identity.innerHTML = '<table align="center"><tr><td class="smredbold" align="center"><img src="images/sitewide/iconsmallalert.gif"> Are you sure you want to delete this item reminder?</td></tr><tr><td align="center"><input type="Image" src="images/buttons/BT_yes_orange.gif" onclick="document.itemform.deleteemail.value=\'1\'; document.itemform.submit(); return false;"><input type="Image" src="images/buttons/BT_no_white.gif" onclick="notSure( \''+control+'\' );"></td></tr></table>';
	return false;
}

function youSure3( control ){
	identity = document.getElementById( control );
	identity.innerHTML = '<table align="center"><tr><td class="smredbold" align="center"><img src="images/sitewide/iconsmallalert.gif"> Are you sure you want to delete this top 10 list reminder?</td></tr><tr><td align="center"><input type="Image" src="images/buttons/BT_yes_orange.gif" onclick="document.topform.deleteemail.value=\'1\'; document.topform.submit(); return false;"><input type="Image" src="images/buttons/BT_no_white.gif" onclick="notSure( \''+control+'\' );"></td></tr></table>';
	return false;
}

function notSure( control ){
	identity = document.getElementById(control);
	identity.innerHTML = ''
	return false;
}
