// toggle global dropdown list
function goDlpWorldwide() {
    var locales = document.getElementById("global_locale").getElementsByTagName("UL");
    var sublocales = document.getElementById("sublocales");
    /*var locales = document.getElementById("global_locale").getElementsByTagName("LI");
    for (var i=0; i<locales.length; i++){
			    if (this.className != "expanded") { this.className += "expanded"; }
			    else { this.className = this.className.replace("expanded", ""); }
    }*/

    if (sublocales.className != "expanded") { sublocales.className = "expanded"; }
    else { sublocales.className = sublocales.className.replace("expanded", ""); }
}

function blurDlpWorldwide() {
    document.getElementById("sublocales").className = document.getElementById("sublocales").className.replace("expanded", "");
}

function doDlpGlobalSearch() {
    if (document.getElementById("ctl00_header_txtSearchString").value == 'Search DLP.com') {
        document.getElementById("ctl00_header_txtSearchString").value = '';
        document.getElementById("ctl00_header_txtSearchString").focus();
        document.getElementById("ctl00_header_txtSearchString").className='search_on';
	} else {
        if (document.getElementById("ctl00_header_txtSearchString").value == ''){
            document.getElementById("ctl00_header_txtSearchString").focus();
            document.getElementById("ctl00_header_txtSearchString").className='search_on';
        }
	}
}
function blurDlpGlobalSearch() {
    var searchBox=document.getElementById("ctl00_header_txtSearchString");
    searchBox.className='off';
    if(searchBox.value==''){searchBox.value='Search DLP.com';}
}
function isGlobalSearchValid() {
    var searchStr = document.getElementById("ctl00_header_txtSearchString").value;
    return (searchStr.length > 0);
}

function clearZip(isPostal)
{
	//zipBox = first input tag within the zipTable div, which is the zipcode box (hopefully)
	var zipBox = document.getElementById("txtZip_cell").getElementsByTagName("input")[0];
	if(zipBox.value == "Enter ZIP Code" || zipBox.value == "" || (isPostal == "1" && zipBox.value == "Enter ZIP/Postal"))
	{
		zipBox.value = "";
		zipBox.focus();
	}
}

function newWin(url)
{
    var success = window.open(url, "popup", "width=750,height=500,scrollbars=1,toolbar=0,location=0,menubar=0,status=0");	
    if (!success) raiseError("You must enable pop-ups to view this feature.");
}

function positionStoreLocator()
{
	var rightbar = document.getElementById("rightbar");
	
	if(window.width) var pageWidth = window.width;
	else if(document.body.clientWidth) var pageWidth = document.body.clientWidth;
	else var pageWidth = document.documentElement.clientWidth;
	
	var halfWidth = pageWidth*.5;
	rightbar.style.left = (halfWidth + 327) + "px";
}

function toggleHomeBanners(banner)
{
    var homeBanners = document.getElementById("banner_home").getElementsByTagName("DIV");

    /*turn off all other banners*/
    for (var i=0; i<homeBanners.length; i++){
        homeBanners[i].style.display='none';
    }
    /*turn on selected banner*/
    var j = banner-1;
    if (homeBanners[j].style.display=='none') {
        homeBanners[j].style.display='block';
    }
}

// old video popup generator (as of 20090303)
function demoPop(demoType)
{
	var presenter;
	// defaults for long demo
	    var w = 500;
	    var h = 425;
	    if (!demoType || demoType=='' || demoType=='long') { demoType = "flash"; }
    // short demo
	    if (demoType=='short') {
	        demoType = "flash_short";
	        w = 480;
	        h = 360; }
    // briliant color
	    if (demoType=='hdtv' || demoType=='projectors') {
	        w = 320;
	        h = 220; }
    // cinema trailer
	    if (demoType=='cinema') {
            w = 480;
            h = 255; }
	// cinema trailer new
	    if (demoType=='cinema_2008') {
            w = 620;
            h = 460; }
   // Filter-free video
	    if (demoType=='filterfree_demo08') {
            w = 320;
            h = 270; }
   // How delp works
	    if (demoType=='how_dlp_works') {
            w = 340;
            h = 260; }
	// Pico Discovery Kit demo
	    if (demoType=='picodk_demo08') {
            w = 320;
            h = 270; }
			
	var winl = (screen.availWidth - w) / 2;
	var wint = (screen.availHeight - h) / 2;
	presenter = window.open('/includes/demo_'+demoType+'.aspx','newWindow','height='+h+',width='+w+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top='+wint+',left='+winl);
	presenter.focus();
}
// new video popup generator (as of 20090303)
function videoPop(videoType)
{
	var presenter;
	// defaults for long demo
	if (!videoType || videoType=='' || videoType=='long') { 
		videoType = "demo";
	    var w = 400;
	    var h = 330;}
    // short demo
	    if (videoType=='tech') {
	        w = 480;
	        h = 350; }
    // briliant color
	    if (videoType=='brilliantcolor') {
	        w = 320;
	        h = 210; }
	// cinema trailer
	    if (videoType=='cinema') {
            w = 720;
            h = 290; }
   // Filter-free video
	    if (videoType=='filterfreeprojectors') {
            w = 400;
            h = 330; }
	// Pico Discovery Kit demo
	    if (videoType=='picodevkit') {
            w = 320;
            h = 270; }
	// PISD Testimonial
	    if (videoType=='testimonial_pisd') {
            w = 400;
            h = 330; }		
			
	var winl = (screen.availWidth - w) / 2;
	var wint = (screen.availHeight - h) / 2;
	presenter = window.open('/includes/video_'+videoType+'.aspx','newWindow','height='+h+',width='+w+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top='+wint+',left='+winl);
	presenter.focus();
}


/* modified popup -- hardcoded DLP subdomain */
function pg_cengine(vcode, partnum)
{
	var url = "/dlp_out_buynow.aspx?to=dlp.pgpartner.com/search_getprod.php&vcode=" + vcode + "&partnum=" + partnum;
	var features = "height=500,width=840,innerHeight=450,innerWidth=550,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes";
		
	window.open(url, "", features);
}

function optionChange(mySelectMenu)
{
	if (mySelectMenu.options[mySelectMenu.selectedIndex].value != '')
	{
		location.href = mySelectMenu.options[mySelectMenu.selectedIndex].value;
	}
}

function confirmClear() 
{
	if (confirm("Are you sure you want to clear the form?")) {
		document.aspnetForm.reset();
	}
}

function goTo(url)
{
	var box = document.getElementById("centerbar").getElementsByTagName("select")[0];
	var destination = box.options[box.selectedIndex].value;
	if (destination) location.href = url + "#" +destination;
}

function popPageWin(url,popW,popH) 
{
	var winl = (screen.availWidth - popW) / 2;
	var wint = (screen.availHeight - popH) / 2;
    presenter = window.open(url,
                            "newDLPWindow",
                            "height=" + popH + 
                            ",width=" + popW + 
                            ",top=" + wint + 
                            ",left=" + winl + 
                            ",toolbar=no,directories=no,status=no" + 
                            ",menubar=no,scrollbars=yes,resizable=yes");
    presenter.focus();
}
function popPageWinNoScroll(url,popW,popH) 
{
	var winl = (screen.availWidth - popW) / 2;
	var wint = (screen.availHeight - popH) / 2;
    presenter = window.open(url,
                            "newDLPWindow",
                            "height=" + popH + 
                            ",width=" + popW + 
                            ",top=" + wint + 
                            ",left=" + winl + 
                            ",toolbar=no,directories=no,status=no" + 
                            ",menubar=no,scrollbars=no,resizable=yes");
    presenter.focus();
}

//Courtesy of Aaron Puga, 2007 08 09, who probably stole it from someone else.
function getParameter( parameterName ) {
  var queryString = window.location.search.substring(1);
  //alert(queryString);
  //if (queryString.length==0) {return "null";}
  var parameters = new Array();
  parameters = queryString.split('&');
  for(var i = 0; i < parameters.length; i++) {
    //alert(parameters[i]);
    //alert(parameters[i].indexOf(parameterName));
    if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
      //alert(parameters[i]);
      var parameterValue = new Array();
      parameterValue = parameters[i].split('=');
      return parameterValue[1];
    }
  }
  return "null";
}