// Empties field elements on focus

function form_fields(FieldId,Status,FieldType)
{
	var FieldElement = document.getElementById(FieldId);
	
	switch(FieldType)
	{
		case 'inline':
		if(FieldElement.value == '&nbsp;'
		|| FieldElement.value == ' '
		|| FieldElement.value == 'Enter keywords'
		|| FieldElement.value == 'Search this blog')
		{
			FieldElement.value = "";
		}
		break;
		case 'block':
		if(FieldElement.innerHTML == '&nbsp;' || FieldElement.innerHTML == ' ' || FieldElement.innerHTML == 'Enter comments')
		{
			FieldElement.innerHTML = "";
		}
		break;
	}
	switch(Status)
	{
		case 1:
		FieldElement.style.backgroundColor = '';
		break;
		case 0:
		FieldElement.style.backgroundColor = '';
		break;
	}
}


// Controls the rollover states for input buttons and submits

function button_rollover(ButtonState,ButtonId)
{
	if(1 == ButtonState)
	{
		document.getElementById(ButtonId).style.backgroundPosition='left bottom';
	}
	else
	{
		document.getElementById(ButtonId).style.backgroundPosition='left top';	
	}
}

        var legalWindow = null;
        //Opens the popup window having ddisclaimer, about, policy, term sections        
        function OpenPage(link)
		{
			if (legalWindow != null){
				if(!legalWindow.closed)
					legalWindow.close();
			}			
			var top=300;
            var left=20;			
            if (window.screen && window.screen.height && window.screen.width)
            {
				top = (screen.height-70)/2-250;
				left = screen.width/2-300;			
			}
						
			legalWindow = window.open(link,'newwin',
			'left=' + left + ',top=' + top + ',width=600,height=500,toolbar=1, scrollbars=1,resizable=0');			
			
			legalWindow.focus();	
		}
		
		//Opens the definitions page
		var definitionWindow = null;
		function OpenDefnPage(link)
		{
			if (definitionWindow != null){
				if(!definitionWindow.closed)
					definitionWindow.close();
			}			
			var top=300;
            var left=20;			
            if (window.screen && window.screen.height && window.screen.width)
            {
				top = (screen.height-70)/2-85;
				left = screen.width/2-112;			
			}
				
			
			definitionWindow = window.open(link,'newwin',
			'left=' + left + ',top=' + top + ',width=225,height=170,toolbar=0, scrollbars=1,resizable=0,status=0,menubar=0');	
			
			definitionWindow.focus();						
		}
		
		var registerWindow = null;
		function OpenRegisterPage(link)
		{
			if (registerWindow != null){
				if(!registerWindow.closed)
					registerWindow.close();
			}
			//Adjust the height according to the screen resolution
			var height =800;
			var left=20;
			if (window.screen && window.screen.height && window.screen.width)
			{
				height = screen.height-70;
				left = screen.width/2-380;			
			}			
			registerWindow=window.open (link, 'popupwindow','top=5,width=760,left=' + left + ',' + 'height=' + height + ',scrollbars,resizable');
			registerWindow.focus();						
		}
		
		var authorWindow = null;
		//Opens the link page to confirm the redirection of authorLink
		function confirmNavigation(authorUrl,link){
			
			link=link + "?Author=" + authorUrl;
			if (authorWindow != null){
				if(!authorWindow.closed)
					authorWindow.close();
			}
			var top=300;
			var left=20;
			
			if (window.screen && window.screen.height && window.screen.width)
			{
				top = (screen.height-70)/2-125;
				left = screen.width/2-150;			
			}
			
			authorWindow = window.open(link,'newwin',
			'left=' + left + ',top=' + top + ',width=300,height=250,toolbar=0, scrollbars=0,resizable=0,status=0,menubar=0');	
		    authorWindow.focus();
		}
		
		function redirectAuthor(authorUrl){
       
			window.opener.location.href = authorUrl
			window.close();
		}
		

		var registerWindow = null;
		function OpenImagePage(link)
		{
			if (registerWindow != null){
				if(!registerWindow.closed)
					registerWindow.close();
			}
			
			//Adjust the height according to the screen resolution
			var top =0;
			var left=20;
			if (window.screen && window.screen.height && window.screen.width)
			{
				height = 850;//window.screen.height-150;
				left = 0;			
			}			
			registerWindow=window.open (link, 'popupwindow','top=0,width=800,left=0,height=' + height + ',toolbar=0, scrollbars=1,resizable=0,status=0,menubar=0');
			registerWindow.focus();						
		}

		var navpopupWindow = null;
		//Generic navigation confirmation function
		//Opens a popup displaying confirmation request before redirecting user
		function confirmNavigationPopUp(redirectUrl,link){            

            if (readCookie("LegalViewed") != null) 
            {
                window.location.href = redirectUrl;
            }
            else
            {
			    link=link + "?redirectUrl=" + redirectUrl;
			    if (navpopupWindow != null){
				    if(!navpopupWindow.closed)
					    navpopupWindow.close();
			    }
    		    
			    var top=300;
			    var left=20;
    			
			    if (window.screen && window.screen.height && window.screen.width)
			    {
				    top = (screen.height-70)/2-125;
				    left = screen.width/2-150;			
			    }    			    			
    			
			    navpopupWindow = window.open(link,'confirmpopup','left=' + left + ',top=' + top + ',width=400,height=400,toolbar=0, scrollbars=0,resizable=0,status=0,menubar=0');	
		        navpopupWindow.focus();		       		       
		    }
		}
		
		function redirectUser(redirectUrl){       
            createCookie("LegalViewed", "true", 365);
			window.opener.location.href = redirectUrl
			window.close();
		}
		
		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 createCookie(name,value,days) {
	        if (days) {
		        var date = new Date();
		        date.setTime(date.getTime()+(days*24*60*60*1000));
		        var expires = "; expires="+date.toGMTString();
	        }
	        else var expires = "";
	        document.cookie = name+"="+value+expires+"; path=/";
        }
        
       
        //Handle keyboard carriage return key press for search control
        function clickButton(e, buttonid)
        { 
            var bt = document.getElementById(buttonid);        
             
            if (typeof bt == 'object')
            { 
                if(navigator.appName.indexOf("Netscape")>(-1))
                {
                    if (e.keyCode == 13)
                    { 
                       bt.click(); 
                       return false; 
                    } 
                } 
                if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
                {
                    if (event.keyCode == 13)
                    {
                        bt.click(); 
                        return false; 
                    }
                }
            }
        }
        
