var popupWin =null;
var strSealURL='weblogos.dnb.com';
var sealID='42B6CC1B-9E18-459C-B173-9C61662B9E9F';
var strDuns='024357563';
var strRWSPath='express.dnbsearch.com';
var strCountry='US';
var increment='true';
var RootLink = "../";
var RootLinkS = "../";
var movieName = "newsmedia";


	function thisMovie(movieName) {
		  // IE and Netscape refer to the movie object differently.
		  // This function returns the appropriate syntax depending on the browser.
		  if (navigator.appName.indexOf ("Microsoft") !=-1) {
		    return window[movieName]
		  } 
		  if(navigator.userAgent.indexOf("Firefox")!=-1){
			return document.embeds[movieName]
		  }
		  else {
		    return document[movieName]
		  }
	}
	
	function playmovie(testVideo) {
			document.getElementById('media_container').style.margin = '0';	
  			thisMovie(movieName).LoadMovie(0, "newsfiles/" +testVideo+ ".swf");
			 
	}

   function loadWishList(dept,cat,prod) {
        location.href="../wishlist-main.aspx?dept=" + dept + "&cat=" + cat + "&prod=" + prod + "&options=" + getOptions(prod) + "&personalize=" + getPersonalize(prod);    
   }
   
   
   function resetLeftCountry(country) {
    document.fLang.submit();
   }
   
   function resetCountry(country) {
    location.href="orderform.asp?code=" + country;    
   }
     
   function orderNow(dept,cat,prod) {
        var myHREF="../preorderform.asp?dept=" + dept + "&cat=" + cat + "&prod=" + prod + "&options=" + getOptions(prod) + "&qty=" + getQuantity(prod) + "&personalize=" + getPersonalize(prod);
        location.href=myHREF;
   }
   
     
   
   function getPersonalize(prod) {
    var lsVal = "";
     //'for ( var i=0; i<document.form2.elements; i++ )
      //'{
        // alert( eval("document.form2.field" + i + ".value") );
     // }
    //if (isObject(eval("document.form2.options_" + prod)) == true) {
        //box.options[box.selectedIndex].value
        //return(eval("document.form2.options_" + prod + "[document.form2.options_" + prod + ".selectedIndex].value"));
        for (var i = 0; i < document.form2.elements.length; i++) {
         if (document.form2.elements[i].name == "personalize_" + prod) {
            if (document.form2.elements[i].checked == true) {
                return("yes");
            }
            
         }
         
       }
        return("no");
    //}
    //else {
    //    return("FRED");
    //}
    
   }   

   function openBig(pProd,wValue,hValue) {
		if (popupWin != null){
			if (navigator.appName == "Netscape") {
				popupWin=null;
				popupWin = pProd;	
				popupWin = window.open(pProd,null,'width=' + wValue + ',height=' + hValue + ',left=' + screen.avalWidth - (wValue/2) + 'screeny=0,top=0,screenx=' + screen.avalWidth - (wValue/2) + ',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
				popupWin.focus();
				popupWin=null;
				popupWin.close();
			}
			else {
				popupWin.close();
			}
		}
		popupWin = pProd;	
				popupWin = window.open(pProd,null,'left=0,top=0,width=' + wValue + ',height=' + hValue + ',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
				//popupWin.moveTo(0,0);
        if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") ){
        popupWin.focus();
        }
   }
   
   function openBig2(pProd,wValue,hValue) {
		if (popupWin != null){
			if (navigator.appName == "Netscape") {
				popupWin=null;
				popupWin = pProd;	
				popupWin = window.open(pProd,null,'width=' + wValue + ',height=' + hValue + ',left=' + screen.avalWidth - (wValue/2) + 'screeny=0,top=0,screenx=' + screen.avalWidth - (wValue/2) + ',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
				popupWin.focus();
				popupWin=null;
				popupWin.close();
			}
			else {
				popupWin.close();
			}
		}
		popupWin = pProd;	
		popupWin = window.open(pProd,null,'width=' + wValue + ',height=' + hValue + ',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=0,left=520');
		//popupWin.moveTo(screen.availWidth-380,0);
        if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") ){
        popupWin.focus();
        }
   }
   
   function SubmitMe(SelectBox) {
		location.href = SelectBox;
   }
   
   function mouseovertd (o){
    o.style.backgroundColor="#5f8cc7";
	o.style.cursor="hand";
	o.style.borderStyle="solid"
	o.style.borderColor="#003366"
	o.style.color="#ffffff"	
}

function mouseouttd (o){
	o.style.backgroundColor="#ededed"
	o.style.color="#003366"
	o.style.borderColor="#e2e2e2"
}

function newscreen4() {
	window.open("","talk","width=300,height=204,resizable=no,scrollbars=auto")
}



function turnOn(imageName) {
  if (document.images) {
	//alert(eval(imageName + "on.src"));
    document[imageName].src = eval(imageName + "on.src");
  }
}

function turnOff(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "off.src");
  }
}

function Rcertify() 
{
popupWin = window.open('http://www.bbbonline.org/cks.asp?id=103082714133734521', 'Participant','location=yes,scrollbars=yes,width=450,height=300'); 
window.name = 'opener';
} 

function exp(strTag ,strAttribute){ 
		var elem = document.getElementsByTagName(strTag); 
		var elem1 =window.event.srcElement; 
		for (var i=0;i<elem1.children.length;i++){ 
			elem1.children[i].innerText=="4"?elem1.children[i].innerText="5":elem1.children[i].innerText="4"; 
		} 
		for (var i =0;i<elem.length;i++) { 
			if(elem[i].getAttribute(strAttribute)=="yes") { 
				elem[i].style.display=='none'? elem[i].style.display='block':elem[i].style.display='none'; 
			} 
		} 
	} 
	

var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365)); 


//setCookie('Cookie Name ',this.form.cookieName.value,expdate)


function setCookie(name, value, expires, path, domain, secure) {


var thisCookie = name + "=" + escape(value) +

((expires) ? "; expires=" + expires.toGMTString() : "") +

((path) ? "; path=" + path : "") +

((domain) ? "; domain=" + domain : "") +

((secure) ? "; secure" : "");

document.cookie = thisCookie;

}

function hideIt(what,hidden,imageName,Caption,url)
{
   var obj = document.getElementById(what);
   
   if (hidden==1) {
    obj.visible = 'false';
    obj.style.display = "none";
   }
   else {
    var sBox=document.getElementById("SwatchBox");
    var sBoxTop = sBox.offsetTop;
	var sBoxLeft = sBox.offsetLeft;
	
	obj.style.top = sBoxTop;
    obj.style.left = getElementPosition("SwatchBox") + 22;
    obj.style.width = '155px';
    obj.style.height = '130px';
    obj.style.zIndex = 999;
    obj.innerHTML = "<table bgcolor='#ffffff' style='border-style:solid;border-width:1px;border-color:Black' cellpadding=2 cellspacing=0 width='100%'><tr><td align=center><img class='searchImage' src='" + url + "itemImages/" + imageName + "'/><span style='background-color:Black'><img src=" + url + "images/1x1.gif style=' width:100%;height:1px' /></span></td></tr><tr><td align=center>" + Caption + "</td></tr></table>";
    //obj.src = '../swatch.asp?pic=' + imageName + '&Caption=' + Caption;
    obj.style.display = "block";
    obj.visible = 'true';
   }
   
}

function getElementPosition(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return offsetLeft;
    //return {left:offsetLeft, top:offsetTop};
}

function orderMultiple(ID) {
    var lsAddOn = "";
    //for (var i=0; i<ID ;i++) {
        //lsAddOn = lsAddOn + "&option=10";   
    //}
    
    if (location.href.indexOf("?") < 0) {
        document.form2.action = location.href + "?add=1" + lsAddOn;
    }
    else {
        document.form2.action = location.href + lsAddOn;    
    }
    
    document.form2.submit();
}

function cboLanguage_onchange() {
    document.fLang.txtLanguage.value = document.fLang.cboLanguage.value;
    document.fLang.submit();
    //location.reload(true);
    return true;
}

function change_OptionValues(prod) {
    for (var i = 0; i < document.form2.elements.length; i++) {
         if (document.form2.elements[i].name == "options_" + prod) {
           //var lblSale = document.form2.elements[i][document.form2.elements[i].selectedIndex].text;                      
           //lblSale = lblSale.toString().substring(lblSale.toString().indexOf("$"));
           var lblSKU = document.form2.elements[i][document.form2.elements[i].selectedIndex].value;
           lblSKU = lblSKU.toString().substring(lblSKU.toString().indexOf(";") + 1);
           eval("document.all.lblSKU_" + prod + ".innerHTML = lblSKU");
           
           var hiddenCosts = eval("document.form2.hidden_" + prod + ".value");
           var myElement = document.form2.elements[i].selectedIndex;
           var myCost = hiddenCosts.split(";")
           eval("document.all.lblSale_" + prod + ".innerHTML = '$' + CurrencyFormatted(myCost[myElement])");
           //eval("document.all.lblSale_" + prod + ".innerHTML = lblSale");
           
           break;
         } 
    }    
}

  function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function change_OptionValuesProduct(prod) {
    for (var i = 0; i < document.form2.elements.length; i++) {
         if (document.form2.elements[i].name == "options_" + prod) {
           var lblSale = document.form2.elements[i][document.form2.elements[i].selectedIndex].text;                      
           var hiddenCosts = eval("document.form2.hidden_" + prod + ".value");
           var myElement = document.form2.elements[i].selectedIndex;
           var myCost = hiddenCosts.split(";")
           eval("document.all.lblSale_" + prod + ".innerHTML = '$' + CurrencyFormatted(myCost[myElement])");
           //eval("document.all.lblSKU_" + prod + ".innerHTML = lblSKU");
           break;
         } 
    }    
}

function getOptions(prod) {
    var lsVal = "";
    for (var i = 0; i < document.form2.elements.length; i++) {
         if (document.form2.elements[i].name == "options_" + prod) {
           lsVal = lsVal + "," + document.form2.elements[i][document.form2.elements[i].selectedIndex].value;           
         } 
    }
    if (lsVal.toString().substring(0,1) == ",") {lsVal = lsVal.substring(1);}
    return(lsVal);        
}
   
function getQuantity(prod) {
    var lsVal = "";
    for (var i = 0; i < document.form2.elements.length; i++) {
         if (document.form2.elements[i].name == "qty_" + prod) {
           lsVal = document.form2.elements[i].value;
         } 
    }
    
    if (lsVal == "") { lsVal=1; }
    return(lsVal);        
}

function expHome(strTag ,strAttribute){ 

		var elem = document.getElementById(strTag); 
		if(elem.getAttribute(strAttribute)=="yes") { 
				elem.style.display=='none'? elem.style.display='block':elem.style.display='none'; 
		} 
		 
	} 
	
	function expHomeImg(strTag ,strAttribute){ 

		var elem = document.getElementById(strTag); 
		if(elem.getAttribute(strAttribute)=="yes") { 
				elem.style.display=='none'? elem.style.display='block':elem.style.display='none'; 
		} 
		
		if (elem.style.display=='none') {
		    eval("img" + strTag).src = "../images/arrow-blue.gif"; 
		}
		else {
		    eval("img" + strTag).src = "../images/red-x.gif"; 
		}
		
		
	} 
	

	function OpenModalWindow(URL,width,height) {
	    var newwindow = ''
	    if (!newwindow.closed && newwindow.location) {
		    newwindow.location.href = URL;
	    }
	    else {
		    newwindow=window.open(URL,'name','height=' + height + ',width=' + width + ',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
		    if (!newwindow.opener) newwindow.opener = self;
	    }
	    if (window.focus) {newwindow.focus()}
	    return false;      
    }	
    
    function ClosePopUp(cntrl)
	{	
	    opener.document.getElementById(cntrl).value = document.getElementById('txtCatg').value; 
	    window.close();
		return true;
	}	
	
	 var http = createRequestObject();
 function createRequestObject() 
     {
           var xmlhttp;
	 try 
                 { 
                    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
                 }
	  catch(e) 
                 {
	    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	    catch(f) { xmlhttp=null; }
	    }
	        if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
                        {
	  	   xmlhttp=new XMLHttpRequest();
	           }
		   return  xmlhttp;
 }
 
function sndRating(idnum,rateval) 
  {
	var dvelement = document.getElementById('dv'+idnum);
             dvelement.innerHTML = "<img src='images/progressimgred.gif'>";
            try
              {
                 http.open('GET', 'ratingprocess.asp?id='+idnum+'&rateval='+rateval);
                 http.onreadystatechange = handleResponseText;
	    http.send(null);
	 }
	    catch(e){}
	    finally{}
 }
function handleResponseText() 
  {
     try
         {
             if((http.readyState == 4)&& (http.status == 200))
                {
    	          var response = http.responseText;
                       var update = new Array();

                    if(response.indexOf('|') != -1) 
                       {
                          update = response.split('|');
                          var drelement = document.getElementById('dv'+update[0]);
                          var voteres = document.getElementById('vot'+update[0]);
                          var totalvote = document.getElementById('tv'+update[0]);
                          var starimg = document.getElementById('star'+update[0]);
                          drelement.style.display ='none';
                          voteres.innerHTML = update[2];
                          totalvote.innerHTML = update[3];
                          starimg.innerHTML = update[4].toString();
             }
	        }
        }
	catch(e){alert("an error occured");}
	finally{}
}