﻿// JScript File

var siteLanguages = [
    ["English (International)", "" ],
    ["English (International)", "en-US"],
    ["中文 (Chinese)", "zh-CN"],
    ["日本語 (Japanese)", "ja-JP"],
    ["한국어 (Korean)", "ko-KR"]
];

var browser = navigator.appName
var ver = navigator.appVersion

function assignEnterKey(buttonId)
{

    if((event.which && event.which == 13) || (event.keyCode && event.keyCode ==13))
    {
    
        document.getElementById(buttonId).click();
        event.returnValue = false;
        return false;
    }
    else 
    {
        return true;
    }
}


function GetCurrentLanguage()
{

    var currentCulture = ReadCookie("CultureSelection");
    
     for (i = 0; i < siteLanguages.length; i++)
     { 
        if (siteLanguages[i][1] == currentCulture)
        {
       
            return siteLanguages[i][0];
        }        
     }

    return siteLanguages[0][0];
}
function popWindow(url)
{
    
   window.open(url, "", "toolbar=0,status=1,scrollbars=1,resizable=1,menubar=0,width=720,height=550, screenX=15, screenY=50, top=15, left=50");
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );
  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
 
  document.cookie = cookie_string;
  
}

function OpenImage(url)
{
	
	width = 920;
	height=700;
	
    url = "/ImageViewer.aspx?i=" + url;
	window.open(url,"ImageViewer","toolbar=0,status=1,scrollbars=1,resizable=1,menubar=0,width=" + width + ",height=" + height + ", screenX=15, screenY=50, top=15, left=50","");

}
function clearSearch()    		
{
    if(document.getElementById('ctl00$HeaderControl1$query').value=='Search')
    {
	    document.getElementById('ctl00$HeaderControl1$query').value='';
    }

}

function SetCulture(culture)
{
    set_cookie("CultureSelection", culture);

    var currentLocation = window.location + "";
    var iLocation = currentLocation.indexOf("?");
    var newLocation = ""
   
   // window.location = newLocation
    var iLocation = currentLocation.indexOf("?");
   
    if (currentLocation.indexOf("cultureSwitch") < 0)
    {
        if (iLocation > 0)
        {   
            newLocation = window.location + "&cultureSwitch=true";
        }
        else
        {
        
            newLocation = window.location + "?cultureSwitch=true";
        }
    }
    else
    {
        newLocation = window.location;
    }
      //window.open(newLocation);
  
   //window.document.location.href = newLocation;
 //  alert(newLocation);
    window.location.href = newLocation;
    return true;
  

}

function ReadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function GetRandomPageQuote()
{
    var rand_no = Math.round(20*Math.random());
    var pageQuoteImage = document.getElementById("ctl00_pageQuoteImageUrl").value;
    document.write("<img src='" + pageQuoteImage + "' border='0' align='right'><br />");

}