﻿// /_scripts/global.js
var w3c = (document.getElementById) ? 1:0
n = (document.layers) ? 1:0
ie = (document.all) ? 1:0
ie6 = (document.getElementById) ? 1:0
var pc	= (navigator.platform.indexOf('Win') == 0) ? 1:0;
var mac	= (navigator.platform.indexOf('Mac') == 0) ? 1:0;

var start_div = 1;
var CurrentImage;

function getQueryVariable(variable) 
{
  var value = "";
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      value = pair[1];
    }
  } 
  
  return value;
    
}

function show(id){
	// Netscape
	if (n)
	{
		document.layers[id].visibility = "show";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{
		document.getElementById(id).style.visibility = "visible";
	}
	else if (ie)
	{
		document.all[id].style.visibility = "visible";			
	}
}


function hide(id){
	// Netscape
	if (n)
	{
		document.layers[id].visibility = "hide";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if (ie6) 
	{
		document.getElementById(id).style.visibility = "hidden";
	}
	else if (ie)
	{
		document.all[id].style.visibility = "hidden";			
	}
}



window.onerror = onError;

n = (document.layers) ? 1:0
ie = (document.all) ? 1:0
ie6 = (document.getElementById) ? 1:0

function onError(sMessage, sURL, sLine) 
{ 
        var sPrompt; 
        sPrompt = "________________________________________________________\n\n" 
        sPrompt += "A client-side javascript error has occured.\n" 
        sPrompt += "________________________________________________________\n\n" 
        sPrompt += "Line:\t" + sLine + "\n" 
        sPrompt += "Reason:\t" + sMessage + "\n" 
        sPrompt += "URL:\t" + sURL + "\n" 
                
        //test to see if this is the development site 
      	if (location.href.indexOf('byteinteractive.com') > 0) 
                window.alert(sPrompt); 
                
        return true; 
 } 

function onLoad()
{ 
	cacheImages();	//function to cache all rollover images
	//window.status = 'Welcome To ';
	return true;
}

function onResize()
{ 
	if (w3c)
		location.reload();
	return;
}

function cacheImages()
{
	var i;
	
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_off\.(gif|jpg)/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off_land.", "_on.");
		}
	}
	return;
}


function SetDefault(sImage)
{
    CurrentImage = sImage
}

function setImage(oImage, pg)
{

	//alert(oImage);
	var i;

    if(pg=="main")
    {
	    //first reset all rollover images to their "off" state
	    for (i=0; i<document.images.length; i++)
	    {
		    if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			    document.images[i].src.replace("_on.", "_off_land.");
	    }
    	
	    //now set the image to be in the "on" state		
	    eval(oImage).src = eval(oImage).src.replace("_off_land.", "_on.");    
    }
    else
    {
	    //first reset all rollover images to their "off" state
	    for (i=0; i<document.images.length; i++)
	    {
		    if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			    document.images[i].src.replace("_on.", "_off.");
	    }
    	
	    //now set the image to be in the "on" state		
	    eval(oImage).src = eval(oImage).src.replace("_off.", "_on.");    
    
    }


				
	return;
}

function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{		
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) > 0 )
		{
			document.images[i].src = document.images[i].src.replace("_on.", "_off_land.");      
	    }
	    
	
	}

    

	return;
}

function clearImage(oImage, pg)
{
    if(pg=="main")
    {
        eval(oImage).src = eval(oImage).src.replace("_on.", "_off_land.");
	}
	else
	{
	    eval(oImage).src = eval(oImage).src.replace("_on.", "_off.");
	}
	return;
}


function openWindow(url, name, width, height, resize, scroll, center)
{
	var sParams = '';
	name = (name == null) ? '' : name;

	sParams += 'width=' + width;
	sParams += ',height=' + height;
	sParams += (resize || resize == 'true') ? ',resizable=yes' : ',resizable=no';
	sParams += (scroll || scroll == 'true') ? ',scrollbars=yes' : ',scrollbars=no';
	sParams += (center || center == 'true') ? ',left=' + ((screen.width - width) / 2) : '';
	sParams += (center || center == 'true') ? ',top=' + ((screen.height - height) / 2) : '';

	window.name = 'opener';
	var popupWin = window.open(url, name, sParams);
	popupWin.focus();
	return;
}

function getDHTMLObj(objName)
{
	if (document.getElementById)
		return document.getElementById(objName);
	else if (document.all)
		return document.all[objName];
	else if (document.layers)
		return document.layers[objName];
	else
		return null;
} 

/* helper functions for flash navigation */
function openFlash() 

{
    var divName = "flashDiv";
    var divWidth = "690px";
    
    if (n)
	{ 
		document.layers[divName].width=divWidth;
	}
	else if (ie6) 
	{
		var obj = document.getElementById(divName);
        obj.style.width=divWidth
	}
	else if (ie)
	{ 
		document.all[divName].style.width=divWidth;
	} 

    
}

function closeFlash()


{
    var divName = "flashDiv";
    var divWidth = "207px";
    
    if (n)
	{ 
		document.layers[divName].width=divWidth;
	}
	else if (ie6) 
	{
		var obj = document.getElementById(divName);
        obj.style.width=divWidth
	}
	else if (ie)
	{ 
		document.all[divName].style.width=divWidth;
	} 
}

function openPrivacy()
{
	window.open('/privacy.aspx','privacy','scrollbars=yes,status=no,width=400,height=400')
}

function openTerms()
{
	window.open('/terms.aspx','terms','scrollbars=yes,status=no,width=400,height=400')
}

function openLegal()
{
	window.open('/legal.aspx','legal','scrollbars=yes,status=no,width=400,height=400')
}

function openCode()
{
	window.open('wherecode.aspx','code','scrollbars=yes,status=no,width=510,height=425')
}

function openCoupon()
{
	window.open('coupon.aspx','coupon','scrollbars=no,status=no,width=490,height=315')
}

function openUniversalAHFlash()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="335" height="400" id="universal335x400" align="middle">');  
document.write ('<param name="allowScriptAccess" value="sameDomain" />');  
document.write ('<param name="movie" value="/ext/arrowhead/Universal/universal335x400.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/ext/arrowhead/Universal/universal335x400.swf" quality="high" bgcolor="#ffffff" width="335" height="400" name="universal335x400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');  
document.write ('</object>');  
}


