//Activate Cloaking

function getCookieVal (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
   }

function GetCookie (name) 
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return null;
   }

function SetCookie (name, value) 
   {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
		

   }

function DeleteCookie (name) 
   {
   var exp = new Date();
   exp.setTime (exp.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
   var cval = GetCookie (name);
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
   //alert("The cookie has been deleted.");
   }
//Deactivate Cloaking-->

//Activate Cloaking
// Can be used to display name on loading of page.
// Requires onLoad in BODY statement
//function DisplayNameOnStartUp()
//   {
//   if(GetCookie('DemoName') != null)
//      {
//      alert("Welcome back "+GetCookie('DemoName'));
//      }
//   }

// Alert box for Test Cookie
function DisplayName()
   {
   if(GetCookie('DemoName') != null)
      alert("Welcome back "+GetCookie('DemoName'));
   else
      alert("You must set the cookie first.");
   }

// Clears text box after setting cookie
function SetTheCookie()
   {
   if(document.forms[0].elements[0].value.length != 0)  
      {
      var expdate = new Date (); 
      expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
      SetCookie('DemoName', document.forms[0].elements[0].value, expdate);  
      alert('Cookie has been set to ' + document.forms[0].elements[0].value + '.');
      document.forms[0].elements[0].value = " ";      
      return false;
      } 
   else 
      {
      alert('You must sign-in first.');
      return false;
      }
   }

// Alert box with instructions for signing-in
function Help()
   {
   alert("INSTRUCTIONS"+"\n"+"\n"+"Step 1  Sign-in in the text box."+"\n"+"\n"+"Step 2  Click on Set The Cookie."+"\n"+"\n"+"Step 3  Click on Test The Cookie."+"\n"+"\n"+"Step 4  Reload page twice."+"\n"+"\n"+"Delete Cookie expires cookie.");
   }

// Alert box to explain viewing the source
//Deactivate Cloaking-->










var go = true;
if (document.location.toString().indexOf('?refreshme=true')!=-1) {
SetCookie('refreshed','true');
go=false;
document.location=document.location.toString().split('?')[0];
}
if (GetCookie('refreshed')=='true' && go) {
SetCookie('refreshed','false');
document.location.reload();
}

var moretxtvalue='';
var nRec = 0;
var related = new Array();
var CurrItemId='addcook';
var ie = false;
var ns6 = false;
var ns = false;
var opera = false;

if (eval(document.layers)) { ns=true; }
else {
    if (eval(document.all)) { ie=true; if (navigator.userAgent.indexOf('Opera')!=-1) opera=true;}
        else {
            if (eval(document.getElementById)) { ns6=true;}
            }
    }








var Currtop = '<br><div class="detail-title" style="border-top:1px solid #D4D9E1;padding-top:13px;">Your Recently Viewed Items</div><div class=rec-div><table class=rec-table><tr>';
var CurrItema = '<td><div class="p1" style="background-image:url(';
var CurrItemab = ')"><a href="';
var CurrItemb = '"><img src=https://p.secure.hostingprod.com/@earthtechproducts.com/ssl/images/spacer.gif width=100 height=90 alt="" border=0><br></a><br></div><div class="link"><p>';
var CurrItemc = '</p></div></td>';
var Currbot = '</tr></table></div><br>';

   function pasteRelated() {
	var items_count=10;
    var asd=0;
    var Rell=false;
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            Rell=true;
            asd=asd+1;
            }
        }
 //alert(GetCookie(ccc));
    if (Rell) {
        document.write(Currtop);
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
			if(i==6){document.write("</tr><tr>");}
            tempvall=GetCookie(ccc).split('-||-');
            document.write(CurrItema);
            document.write(tempvall[0]);
            document.write(CurrItemab);
            document.write(tempvall[1]);
            document.write(CurrItemb);
	        document.write(tempvall[2]);
            document.write(CurrItemc);
            }
        }
        document.write(Currbot);
        }
    } 

function addtorel() {

var items_count=10;

related[CurrItemId]=CurrItem;
rel_itms = new Array();
inarr = false;
  for (i=1;i<=items_count;i++) {
	cc='rel_'+i;
	if (!GetCookie(cc)) {
		SetCookie(cc, related[CurrItemId]);
		break;
	} 
	else {
		if (GetCookie(cc)==related[CurrItemId]){
			break;
		} 
		else {
			for (i=0;i<items_count;i++) {
				ncc='rel_'+(i+1);
				if (GetCookie(ncc)==related[CurrItemId]) inarr=true;
				if (GetCookie(ncc))	rel_itms[i] = GetCookie(ncc);
			}
			if (!inarr){
				if (rel_itms.length == items_count) {
					rel_itms.splice(items_count-1,1);
				}
				rel_itms.unshift(related[CurrItemId]);
				for (i=1;i<=items_count;i++) {
					scc='rel_'+i;
					if (rel_itms[i-1]) {SetCookie(scc, rel_itms[i-1]);}
				}
			}
		}	
	  }
  }
}	

function makeavailable(num,state) {
    obj=eval("document.forms.multiorder.vwquantity"+num)
    obj.disabled=!state;  
    ((state)?(obj.value=1):(obj.value=0))
    obj2=eval("document.forms.multiorder.vwitem"+num)
    obj2.disabled=!state; 
    ((state)?(obj.value=1):(obj.value=0))

for(i=0;i<document.forms.multiorder.elements.length; i++){
obj3 = document.forms.multiorder.elements[i];

	if(obj3.name.indexOf('vwattr'+num+'_')!=-1){
	    obj3.disabled=!state; 
    ((state)?(obj.value=1):(obj.value=0))
	}

} 
	
	//alert(document.forms.multiorder.elements.length)
	
}

function set_pos(){
	obj = document.getElementById('cont7');
	obj1 = document.getElementById('layers_div');
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj1.offsetLeft;
		objTop    = obj1.offsetTop;
		objParent = obj1.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		obj.style.top = objTop+4;
		//alert(obj.style.top)
		obj.style.left = objLeft;
}

function show_c_layer(num){
//alert(num + "   " + activeLayer);
		for(i=1;i<=10;i++){
		if(document.getElementById('hat' + i) && document.getElementById('cont' + i)){

		//alert(url2)
			if(i==num){
				document.getElementById('hat' + i).style.background = 'url(https://p.secure.hostingprod.com/@site.earthtechproducts.com/ssl/images/t2e2.gif)';
				document.getElementById('cont' + i).style.display='block';
				activeLayer = num;
			}
			else{
				document.getElementById('hat' + i).style.background = 'url(https://p.secure.hostingprod.com/@site.earthtechproducts.com/ssl/images/t1e2.gif)';
				document.getElementById('cont' + i).style.display='none';
			}
		}
		
}
}

var activeLayer = 1;

function over_c_layer(num){

		if(activeLayer != num){
			document.getElementById('hat' + num).style.background = 'url(https://p.secure.hostingprod.com/@site.earthtechproducts.com/ssl/images/t2e2.gif)';
		}
}

function out_c_layer(num){
			if(activeLayer != num){
				document.getElementById('hat' + num).style.background = 'url(https://p.secure.hostingprod.com/@site.earthtechproducts.com/ssl/images/t1e2.gif)';
			}
}

function first_layer_ini(){
	for(i=1;i<=10;i++){
	if(document.getElementById('hat' + i) && document.getElementById('cont' + i)){
	activeLayer = i;
 		document.getElementById('hat' + i).className = 't26a2';
		document.getElementById('cont' + i).style.display='block'
		break;
		}
	}    
}

