function AddFavorite_(sURL,sTitle){
    try { 
        window.external.addFavorite(sURL, "Business Tycoon Online, business simulation"); 
    } 
    catch (e) { 
        try { 
            window.sidebar.addPanel("Business Tycoon Online, business simulation", sURL, ""); 
        } 
        catch (e) { 
            
        } 
    } 
}

var myspaceSettings = { 
	consumerKey:'63ddd73ab3234caa952f0ed47ca1c57c', 
	targetDomain: 'http://www.dovogame.com/' 
};

//may change to MSID.init()
//MSID.Connect.init(myspaceSettings);

function handleResponse(response) {
	if (response.statusCode == MSID.Connect.Enums.status.READY) {
		 top.location.href = 'http://www.dovogame.com/myspace/api_myspace.php';
	} else if (response.statusCode == MSID.Connect.Enums.status.COOKIE_NOT_FOUND) {
		//alert('Please logged in)');
	} else if (response.statusCode == MSID.Connect.Enums.status.LIBRARY_INIT_TIMEOUT) {
		//alert('Timeout');
	} else {
		//alert(response.statusCode);
	}
}

function update_user_box() {   
     //var er = FB.Connect.ifUserConnected();
	 
	 var  message = document.getElementById("face_book_user").innerHTML;
	 var box = new Facebox({title: 'Connect With Facebook',message: ''+message+''});
//	 box.show();
	 
	 FB.XFBML.Host.parseDomTree();

}
function onlogin_dovo(){
	window.location.href = '<{$__s__url__}>facebook/api_facebook.php';
}
function usefacebook(){
	//FB.Connect.requireSession(); 
    var uid = FB.Connect.get_loggedInUser(); 
//	window.location.href='<{$__s__url__}>facebook/i.php';

}
function AddFavorite_(sURL,sTitle){
    try { 
        window.external.addFavorite(sURL, "Business Tycoon Online, business simulation"); 
    } 
    catch (e) { 
        try { 
            window.sidebar.addPanel("Business Tycoon Online, business simulation", sURL, ""); 
        } 
        catch (e) { 
            
        } 
    } 
}

function checkEmail() {
	var email = $("#username").attr("value");
	if(email==''){
		$("#wba").show();
		$("#wba").html("<span class=\"bto arrow0\"></span>E-mail is required");
	}
	var myreg = /^([a-zA-Z0-9]+[_|\-|\.]+)*[a-zA-Z0-9_-]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	var result = myreg.test(email);
	if (email == "" || !myreg.test(email)) {
		$("#wba").show();
		$("#wba").html("<span class=\"bto arrow0\"></span>E-mail is required");
	}else{
		$("#wba").hide();
	}
	
}
function checkpw(){
 	var password = $("#password").attr("value");
	if(password == ""){
		$("#wbc").show();
		$("#wbc").html("<span class=\"bto arrow0\"></span><strong>The E-mail or Password you enttered is incorrect</strong><br />Passwords are case sensitive  Please check your Caps Lock ");
	}else{
		$("#wbc").hide();
	}
}

function login(){
	if($('#username').val().length == 0){
		$("#wba").show();
		$("#wba").html("<span class=\"bto arrow0\"></span>E-mail is required");
		return false;
	}else{
		$("#wba").hide();
	}
	
	if($('#password').val().length == 0){
		$("#wbc").show();
		$("#wbc").html("<span class=\"bto arrow0\"></span><strong>The E-mail or Password you enttered is incorrect</strong><br />Passwords are case sensitive  Please check your Caps Lock ");
		return false;
	}else{
		$("#wbc").hide();
	}
	var form1 = document.getElementById('form1');
	form1.submit();
}

//2010-12-10 z
var action = {
	goofpage : function(n){
		n = n?n:0;
		$('html').scrollTop(0);
		}
	}
	
$(document).ready(function(){
	//$("#stateLogin").hover(function(){$(this).find("#stateLoginBox").addClass('hover')},function(){$(this).find("#stateLoginBox").removeClass('hover')}); 
	/*$("#stateLogin").click(function(){$("#stateLoginBox").addClass('hover')});
	$(document).click(function(key){
			var o = key.target || key.srcElement;
			
			if ($(o).parents("#stateLogin").length<1){$("#stateLoginBox").removeClass('hover')}
			});
	var w = $("#userNameBox").find("ul").width();*/
/*	if ($.browser.msie){
		$("#userNameBox").find("a").width(w-19);
		$("#userNameBox").find("a.list").width(w-12);
		}else{
		$("#userNameBox").find("a").width(w);
		$("#userNameBox").find("a.list").width(w+7);
		}*/
	
//	$("#userNameBox").hover(function(){$(this).find(".select").addClass('hover');},function(){$(this).find(".select").removeClass('hover')}); 
//	$("#userNameBox").click(function(){$(this).find(".select").removeClass('hover')});

//$("#stateLogin").hover(function(){$(this).find("#stateLoginBox").addClass('hover')},function(){$(this).find("#stateLoginBox").removeClass('hover')}); 
	$("#stateLogin").click(function(){$("#stateLoginBox").addClass('hover')});
	$(document).click(function(key){
			var o = key.target || key.srcElement;
			
			if ($(o).parents("#stateLogin").length<1){$("#stateLoginBox").removeClass('hover')}
			});
	$("#userNameBox").hover(function(){$(this).find(".select").addClass('hover')},function(){$(this).find(".select").removeClass('hover')}); 
	$(".search").find("input").focus(function(){
			if ($.trim($(this).val())=="Search News"){
				$(this).val("");
				}
			$(this).parent(".search").addClass("hover")});
	$(".search").find("input").blur(function(){
			if ($.trim($(this).val())==""){
				$(this).val("Search News");
				}
			$(this).parent(".search").removeClass("hover")});
});

function gsearch(){
	var key = $("#key").attr("value");
	if(key != "" && key != 'Search The News' ){
		window.location.href = 'news.php?k='+key;
	}else{
		alert("Please enter the keyword.");
	}
}
