window.onload = function() 
{    

    $(document).ready(function() 
    { 
        	$('#searchphrase').keyup(function(e) {			
        			if(e.keyCode == '13') {
            				clickSearch($('#searchphrase').val());
                                	event.preventDefault();   
             			}        		
      		});   
		$(function(){
		    $("#newsAccordion").accordion({
			    autoHeight: false,
			    navigation: false
		    });
	    });
	    
	    
	setEqualHeight($(".lvl1"));
//    $(".leftnavigation .li1:first").css("margin-top","20px");
    var w1 = $(".videoPopup").width();
    
    $(".videoPopup").dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			resizable: false,
			width:w1
	});
	$(".signupPopup").dialog({
			autoOpen: false,
			modal: true,
			resizable: true,
			width: 500
	});
	
	var w2 = $(".imgPopup").width();

	$(".imgPopup").dialog({
			autoOpen: false,
			modal: true,
			resizable: false,
			width:w2
	});
	
	$('#videolink').click(function() {
			$('.videoPopup').dialog('open');
		})
		    
    });    
    //$('.boxEventTricker').toggle();

    
    
}

function boxAnimOver(element,id) {
    $(document).ready(function() {
        //$(element).parent().find('div.boxText').animate({ top: '-=40px' }, 500);
        $('#'+id).animate({ top: '-=40px' }, 500);
    });
}

function boxAnimOut(element,id) {
    $(document).ready(function() {  
        //$(element).parent().find('div.boxText').animate({ top: '+=40px' }, 500);      
        $('#'+id).animate({ top: '+=40px' }, 500);
    });
}

function boxAnimLink(element,url) {
    $(document).ready(function() {
        //var linkValue = $("a", element.parentNode).attr("href");
        //if (linkValue != undefined || linkValue != null) {
        //    location.href = $("a", element.parentNode).attr("href");
        //}
        if (url != undefined || url != null) {
            location.href = url;
           }
    });
}


function setEqualHeight(columns)
{
    var tallestcolumn = 0;
    columns.each(
       function()
       {
          currentHeight = $(this).height();
          if(currentHeight > tallestcolumn)
          {
              tallestcolumn  = currentHeight;
          }
       }
    );
    columns.height(tallestcolumn);
}


jQuery.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

function clearText(element,v)
{
    if(element.value==v)element.value=''
}
function resetText(element,v)
{
	if(element.value=='')element.value=v;
}

function clickSearch(v)
{
//alert("/searchresult.aspx?search="+encodeURI(v)+"&page=1");
//window.location="http://www.google.com";
window.location.href= "/searchresult.aspx?search="+encodeURI(v)+"&page=1";
return true;
}

function search(event,v)
{	
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if( keyCode == 13 ) 
	{
        	clickSearch(v);
		return true;
	}
	else
	{
		return true;
	}
}
function checkEnter(e){
 e = e || event;
 return (e.keyCode || event.which || event.charCode || 0) !== 13;
}



