// JavaScript Document
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_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_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 open_win(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// Function to Clear intial value in a form field
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
function close_window() {
    window.close();
}
function printpage() {
	window.print();  
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// Begin Drop Menus
var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;
var menuTimer = null;

function killMenuTimeOut(){
  if (menuTimer) clearTimeout(menuTimer);
   menuTimer = null;
}

function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);	
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "hidden";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			m.style.visibility = "hidden";			
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {			
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	//MM_menuResetTimeout();
	
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	killMenuTimeOut()
	MM_menuResetTimeout();

	menuTimer = setTimeout(function() 
	{
	MM_menuHideMenus();
	
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
   
    MM_menuShowSubMenu(menuName);
   }, 500);

   //menuTimer = setTimeout("MM_menuShowMenuContainer('" + containName + "','" + xOffset + "','" + yOffset + "','" + triggerName + "');",1000);
	//menuTimer = setTimeout(function() {MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);},1000);

}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	
	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}
// End Drop Menus

//for popup window over images and links
var cX = 0; var cY = 0; 
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;} 
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;} 
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; } 
else { document.onmousemove = UpdateCursorPosition; } 
function AssignPosition(d) { 
	
d.style.left = (cX+10) + "px"; 
d.style.top = (cY+10) + "px"; 

} 
function AssignPositionIE(d) { 
	
var mosX = 0 ;
var mosY = 0 ;

mosX = event.clientX + document.body.scrollLeft ;
mosY = event.clientY + document.body.scrollTop;
}

function HideContent(d) { 
if(d.length < 1) { return; } 
document.getElementById(d).style.display = "none"; 
} 
function ShowContent(d) { 
if(d.length < 1) { return; } 
var dd = document.getElementById(d); 
if (navigator.appName == "Microsoft Internet Explorer"){

AssignPositionIE(dd);
} else {
AssignPosition(dd); 
}
dd.style.display = "block"; 
} 
function ReverseContentDisplay(d) { 
if(d.length < 1) { return; } 
var dd = document.getElementById(d); 
AssignPosition(dd); 
if(dd.style.display == "none") { dd.style.display = "block"; } 
else { dd.style.display = "none"; } 
}

function ShowImageHover(evt, name)
{
    evt = (evt) ? evt : (window.event) ? window.event : ""; 
    
   
    var winW = (!document.all)? window.innerWidth-16 : document.body.offsetWidth-20
    var winH = (!document.all)? window.innerHeight-16 : document.body.offsetHeight-20;
    var leftSide = mouseX>=(winW/2.0);
    
    var layer = $(name+"_view");
	var layerW = layer.offsetWidth;//450;
    var img =  $(name);
    var left = mouseX+10;
    var top = mouseY+10;

    if (leftSide)
        left = (mouseX-(layerW+25));//
    else
        left = (mouseX+25);       
    
    //var right = (mouseX)+layerW;
    //if(right>=winW)
     //   left = (mouseX-layerW);
    
    var bottom = (mouseY+10)+layer.offsetHeight;
    if(bottom>=winH+document.body.scrollTop)
        top = winH+document.body.scrollTop-(layer.offsetHeight+10);
    
    layer.style.left = left+"px";
    layer.style.top = top+"px";
    
    if (layer.style.display!="block")
        layer.style.display = "block";
  // status = "bottom: "+bottom+" winH: "+winH+"  winW: "+winW+" leftSide: "
  // +leftSide+" left: "+left+" top: "+top+" mouseX: "+mouseX+" mouseY: "+mouseY;
}

function openWindow2(url,width,height) {
var newWindow = window.open(url, 'Popup_Window', 'width='+ width +',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');

newWindow.focus();
}

function openWindow3(url,width,height) {
var newWindow = window.open(url, 'Popup_Window2', 'width='+ width +',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');

newWindow.focus();
}

function toggleMe(a,image){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
	document.getElementById(image).innerHTML="- View Less";
  } else {
    e.style.display="none"
	document.getElementById(image).innerHTML="+ View All";
  }
  return true;
}

function toggleMe2(a,image){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
	document.getElementById(image).innerHTML="&#9650;";
  } else {
    e.style.display="none"
	document.getElementById(image).innerHTML="&#9660;";
  }
  return true;
}

function comodossl() {
	window.open("http://www.trustlogo.com/ttb_searcher/trustlogo?v_querytype=W&v_shortname=SC&v_search=http://www.compsource.com/index.asp&x=5&y=5","cssl",
	"directories=0,toolbars=0,height=550,width=500,scrollbars=yes,top=1");
	}
	
function cookies() {
	window.open("/cookies.html","cookies",
"directories=0,toolbars=0,height=550,width=500,scrollbars=yes,top=1");
}

function free_ship() {
	window.open("/free_ship.htm","freeship",
"directories=0,toolbars=0,height=600,width=600,scrollbars=yes,top=1");
}
function please_call() {
	window.open("/please_call.asp","callName",
	"directories=0,tollbar=no,height=295,width=320,top=0,scrollbars=no");
}

function go_page(linkData) {
    var url = linkData + '&compid='+document.compare.compid.value
    document.location=url;
}
function do_compare() {
    var url = "/compare.asp?";
    var f=false;
    var comstr1 = document.compare.compid.value.replace(/%26/ig, '&');
    var comstr2 = comstr1.replace(/%3d/ig, '=');
    var comstr3 = comstr2.replace(/^&/, '');
    url = url + comstr3;
    if(comstr3.length < 1){
        f=false;
    }else {
        f=true;
    }
				    
    if(f) {
        /*document.location=url;*/
		window.open(url, 'compare', 'width=800,height=700,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes')
    } else {
        alert('No products selected');
    }
}
function rebate(t) {
	window.open(t,"winName","scrollbars=yes,toolbar=no,left=150,top=15,width=800,height=600,resizable=1");
}