// Code appended for the game Ubreak By Arnab on Feb 7th 2008 for function popupload and imgpath.
function popUpload()
{
//		alert(girlid+"--"+id);
        xposition=0; yposition=0;
        args = "width=" + 500 + "," 
        + "height=" + 150 + ","
        + "location=0," 
        + "menubar=0,"
        + "resizable=0,"
        + "scrollbars=yes,"
        + "status=0," 
        + "titlebar=0,"
        + "toolbar=0,"
        + "hotkeys=0,"
        + "fullscreen=no,"
        + "left=" + xposition + ","  
        + "top=" + yposition;   
		
        window.open("../upload_image.php3","Window",args);
}

function imgpath(path)
{
	var Imgpath = path;
//	alert (sendText+"---"+sendImg);
	window.document.common.SetVariable("image_path",Imgpath);
}

function game_feedback()
{
	var path = '../feedback.php3';
	var wd = '500'
	var ht = '555'
	var prm = "topmargin=0,leftmargin=0,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=0,copyhistory=no,scrollbars=yes,width="+wd+",height="+ht

	if(wd>0)
			window.open(path,'_blank',prm);

}

function login_auto_redirect()
{
  ////window.location.href="http://www.gaminghungama.com/single/reach-the-pitch-play.php3";
  document.frm.submit();
}


function preloadad(){
	document.getElementById('preloadadid').style.display="block";
	document.getElementById('preloadadid_blank').style.display="none";
    document.getElementById('afterpreloadadid').style.display="none";
	setTimeout("afterpreloadad()",15000);
}

function afterpreloadad(){
	document.getElementById('preloadadid').style.display="none";
	document.getElementById('preloadadid_blank').style.display="none";
    document.getElementById('afterpreloadadid').style.display="block";
}

function findQuickLink(sel){
if(document.getElementById(sel).value!=0){	
	var obj="FindGamesQuickly";
	var url = document.getElementById(sel).value;	
	window.location.href='http://www.gaminghungama.com/HitCounterFindGQuickly.php3?gamename='+obj+'&url='+url;
	}
}

function iframe_loader()
{
    //if(!window.opener.closed)
    //{
       // window.opener.refresh_iframe();
    //}
}

//*******************************************************************************************************

	var c=0;
	var t="";
	var timer_count="";

	function timedCount()
	{		
		//document.getElementById('timer_count').value=c;
		timer_count=c;
		c=c+1;
		t=setTimeout("timedCount()",1000);
	}

	function stopCount(gameid)
	{
		window.clearTimeout(t);
		//addTimeSpendCount(gameid,document.getElementById('timer_count').value);
		addTimeSpendCount(gameid,timer_count);
		timer_count="";
	}
	//window.closed;

//*** auto submit ****************************************************
   var http_request = false;
   function makePOSTRequest(url, parameters,divid) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
     
      http_request.onreadystatechange = function alertContents(){		  
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(divid+"--"+http_request.responseText);
            result = http_request.responseText;
			if(divid!="nodivid"){
				document.getElementById(divid).innerHTML = result;            
			}
         } else {
            //alert('There was a problem with the request.');
         }
      }else{
		if(divid!="nodivid"){
			document.getElementById(divid).innerHTML = "<img src='../images/loading.gif'/>"; 
		 }
	  }
   }
	
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
	  
   };

   
/** below is the functions use to add Time Spend on each game in secounds*/
	function addTimeSpendCount(gid, ts)	{		
		var poststr = "gid=" + encodeURI( gid ) +
					  "&ts=" + encodeURI( ts ) ;
		makePOSTRequest('http://www.gaminghungama.com/submit_time_spend_count.php', poststr, 'nodivid');
	};
/** above is the functions use to add Time Spend on each game in secounds*/

/** below is the functions use to add vote for the game*/
	function vote(obj, gameid){
		var poststr = "gid=" + gameid +
					  "&vote=" + obj ;		
		makePOSTRequest('../submit_vote_for_game.php', poststr, 'votedivid');
	};


	function submitViewAllGames_DHTML_clicks(obj)	{
		var poststr = "gamename=" + encodeURI( obj );
		makePOSTRequest('http://www.gaminghungama.com/HitCounter.php3', poststr, "nodivid");
	}


	function submitHideAllGames_cookey_clicks(obj)	{
		var poststr = "hidegamelist=" + encodeURI( obj );
		makePOSTRequest('http://www.gaminghungama.com/close_dhtml_game_list_status.php', poststr, "nodivid");
	}

	
	function email_subscriber(){
		var path = '/emailer_subscriber.php';
		var prm = "topmargin=0,leftmargin=0,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=0,copyhistory=no,scrollbars=no,width=485,height=260"
		window.open(path,'email_subscriber',prm);
	}


	function refresh_iframe()
	{
		var x = 0;
		var ilen = document.getElementsByTagName('iframe').length;
		if(ilen>0)
		{
			for(x=0; x<ilen; x++)
			{
				document.getElementsByTagName('iframe')[x].src = document.getElementsByTagName('iframe')[x].src;
			}
		}
	}



	function forgot_pass_window(){
		var hWnd = window.open('/forgot_password.php3',"ForgotPassWindow","width=515,height=325,resizable=no,scrollbars=yes, left=0, top=0");
		if (hWnd.focus != null) hWnd.focus();
	}
	function NewWindow(url){
		var hWnd = window.open(url,"HelpWindow","width=300,height=300,resizable=no,scrollbars=yes, left=80,top=20");
		if (hWnd.focus != null) hWnd.focus();
	}
	function tell_a_friend(){
		var path = 'tellAfriend.php3';
		var prm = "topmargin=0,leftmargin=0,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=0,copyhistory=no,scrollbars=no,width=500,height=430"
		window.open(path,'_blank',prm);
	}
	function openterm(url,wd,ht)
	{
		var path = url;
		var prm = "topmargin=0,leftmargin=0,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=0,copyhistory=no,scrollbars=yes,width="+wd+",height="+ht
		if(wd>0)
		window.open(path,'_blank',prm);
	}
	function register_now(){
		window.opener.location.href='/register.php3';
		window.close();
	}

	function forumlogin(points, avatar, rank, username, pass)	{
		var poststr = "done=1" +
					"&total_points=" + encodeURI( points ) +
					"&avatar=" + encodeURI( avatar ) +
					"&rank=" + encodeURI( rank ) +
					"&username=" + encodeURI( username ) +
					"&password=" + encodeURI( pass );
		makePOSTRequest('http://www.gaminghungama.com/forums/login.php', poststr, 'nodivid');
	}
	