﻿// JScript File

function rollover(obj, newImage) {
    obj.src = newImage;
  }
  
function noEnter(e)
{
    if(window.event) // IE
	{
		keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}
	
	if(keynum == 13)
	{
		doSearch();
		return false;
	}
	else
	{
		return true;
	}
}

function doSearch()
    {
    var txtSearch = "";
    var txtSearch = document.getElementById("search");  
	if(txtSearch.value == "")
		{
		window.alert("Please enter some text first!");
		txtSearch.focus();
		return true;
		}
		
	if(txtSearch.value=="Keyword Search")
		{
		window.alert("Please enter a valid search phrase first!");
		txtSearch.focus();
		return true;
		}

	    window.location.href = "/default.aspx?appid=2354&q=" + txtSearch.value;
    }


var strSearch = "";

function doFocus(txtSearch)
    {
    strSearch = txtSearch.value;
    if(strSearch == "Keyword Search")
        {
        txtSearch.value = "";
        }
    }
    
function doBlur(txtSearch)
    {
    if(txtSearch.value == "")
        txtSearch.value = "Keyword Search";
    }
      
      
var win=null;

function NewWindow(mypage,myname,w,h,scroll,pos)
    {
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2-50:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);
    }          
    
    
   
function NewImage(imageurl, w, h)   
    {
    var imageContainer = document.getElementById("imageContainer");
    if(imageContainer == null)
        {
        var imageContainer = document.createElement('div');
        imageContainer.style.position = "absolute";
        imageContainer.id = "imageContainer";
        document.body.appendChild(imageContainer);
        }
    
    
    
    imageContainer.innerHTML = "<img alt=\"Click to close!\" onClick=\"CloseImage()\" class=\"ImagePopup\" src=\"" + imageurl + "\"></a>";
    imageContainer.style.display = "block";
    
    //imageContainer.style.top = ((screen.height)?(screen.height-h)/2-150:100) + "px";
    //imageContainer.style.left = ((screen.width)?(screen.width-w)/2:100) + "px";
    
    var myWidth = 0, myHeight = 0;
    var scrOfX = 0, scrOfY = 0;

    if(typeof( window.innerWidth ) == 'number' ) 
        {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
        }
    else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)) 
        {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
        }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
        {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
        }
        
    if( typeof( window.pageYOffset ) == 'number' ) 
        {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
        } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
        {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
        }
    else if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
        {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
        }

    imageContainer.style.top = ((myHeight -h)/2 + scrOfY) + "px";
    imageContainer.style.left = ((myWidth - w)/2 + scrOfX) + "px";
    }
    
function CloseImage()
    {
    var imageContainer = document.getElementById("imageContainer");
    imageContainer.style.display = "none";
    }        
    
function removeInputs()
    {
    var ids = new Array("__VIEWSTATE", "__EVENTARGUMENT", "__EVENTTARGET");
    for(var i=0; i<ids.length; i++)
        {
        var obj = document.getElementById(ids[i]);
        obj.value = "";
        obj.name = "obj_" + i;
        }
    }    
    
//function getYearArchive(obj)
//    {
//    var year = obj[obj.selectedIndex].value;
//    var qs = document.location.search;
//    var ind = qs.indexOf("&year=");
//    
//    
//    if(ind == -1)
//        {
//        qs += "&year=" + year;
//        }
//    else
//        {
//        qs = qs.substring(0, ind) + "&year=" + year;
//        }
//        
//    document.location.href = "/default.aspx" + qs;
//    }

function getYearArchive(obj, appid)
    {
    var year = obj[obj.selectedIndex].value;
    document.location.href = "/default.aspx?appid=" + appid + "&year=" + year;
    }
        