// JavaScript Document

/* common js*/
function isValid() {
 var mail=document.form1.email.value;
 if (mail.indexOf(' ')==-1 
      && 0<mail.indexOf('@')
      && mail.indexOf('@')+1 < mail.length
 ) return true;
 else alert ('Invalid email address!')
 return false;
}

function selectname() 
{ 
document.loginForm.login.select()
} 
function dologin(form,login_url)
{
	loginname = form.login.value.split("@");
	if(loginname[1])
		form.login.value=loginname[0];
}

function selecttext() 
{ 
document.form1.email.select()
} 

/* poll js*/
function vote()
	{
	var doc = document.poll;
	var check = false;
	for(i=0;i<doc.options.length;i++)
	{

		if(doc.options[i].checked)
		{
		check = true;
		break;
		}
	}

	if(check)
	{
	window.open("http://polls.oneindia.in/polls.php?submit=submit&catid="+doc.catid.value+"&question="+doc.question.value+"&options="+doc.options[i].value,"poll","width=450,height=300,scrollbars=1;")
	return false;
	}
	else{
	alert("Please choose an option");
	return false;
	}
	return false;
	}
	
	
/* script js*/

// scorecard functions
function fopen4() {
window.open('http://thatscricket.oneindia.in/data/score_data/Aus-Ind-2004-01-09.html','','height=500,width=500,scrollbars');
}

// scorecard functions
function fopen3() {
window.open('http://thatscricket.oneindia.in/data/score_data/Ind-Eng-2002-09-05.html','','height=500,width=500,scrollbars');
}

// dream team contest
function fopen5() {
window.open('http://thatscricket.oneindia.in/specials/wc2003/rules.html','','height=480,width=520,scrollbars');
}

function fopen6() {
window.open('http://thatscricket.oneindia.in/specials/wc2003/prizes.html','','height=300,width=350,scrollbars');
}

// drop down for series on right
function Links(cname) 
{
if(cname=="forthtest")
{
if (document.forth.forthtest.options[document.forth.forthtest.selectedIndex].value != "") 
{location = document.forth.forthtest.options[document.forth.forthtest.selectedIndex].value;}
}

if (cname == "forthloi") {
if (document.fifth.forthloi.options[document.fifth.forthloi.selectedIndex].value != "") 
{location = document.fifth.forthloi.options[document.fifth.forthloi.selectedIndex].value;}
}
if (cname == "recenttest") {
if (document.recent.recenttest.options[document.recent.recenttest.selectedIndex].value != "") 
{location = document.recent.recenttest.options[document.recent.recenttest.selectedIndex].value;}
}
if (cname == "recentloi") {
if (document.recent1.recentloi.options[document.recent1.recentloi.selectedIndex].value != "") 
{location = document.recent1.recentloi.options[document.recent1.recentloi.selectedIndex].value;}
}
if (cname == "archives") {
if (document.archive.archives.options[document.archive.archives.selectedIndex].value != "") 
{location = document.archive.archives.options[document.archive.archives.selectedIndex].value;}
}

}
//-------------------------------------Captain/Non captain------------------------------------------------------
function getPlayers() {
	
	var cid = window.document.getElementById('country').value;
	alert("hi");
	window.document.location.href=window.document.location.href+"?cid="+cid;
}

//-------------------------------------Team stats------------------------------------------------------

function getCountry(url)
{
	var con = window.document.getElementById('coun').value;
	alert('hi');
	window.document.location.href=url+"?cid="+con;
}
//------------------------------------------------------------------------------------------------------

function check()
{
	var Email= document.subscribe.emailID.value;
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(Email))
  	{
	   	return true;
  	}
  	else
  	{
   		alert("Enter valid Email ID");
		return false;
  	}
}



/* all- scripts*/

function cricterm(termfile){
               window.open('http://thatscricket.oneindia.in/cricket-info/' + termfile, 'Terms','height=400,width=450,scrollbars,scrollbars,resizable=yes,scrollbars=yes');
        }

		
		
		
		
		
// Ball By Ball Pop up
function openWin( windowURL, windowName, windowFeatures ) 
{
	return window.open( windowURL, windowName, windowFeatures ) ;
}

function check()
{
	var Email= document.subscribe.emailID.value;
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(Email))
  	{
	   	return true;
  	}
  	else
  	{
   		alert("Enter valid Email ID");
		return false;
  	}
}







function check() 
{ 
var newslet = document.subscribe; 
if (newslet.emailID.value=="") 
 { 
    alert("Please enter your Name") 
    newslet.emailID.focus(); 
    return false; 
  } 
    else if (newslet.emailID.value=="") 
    { 
    alert("Enter your E-mail ID") 
    newslet.emailID.focus(); 
    return false; 
 } 
    else 
if((newslet.emailID.value.indexOf('.',0)=="-1")||(newslet.emailID.value.indexOf('@',0)=="-1")) 
{ 
 alert("Invalid E-Mail Address") 
    newslet.emailID.focus(); 
    return false; 
} 
} 

function addDomain(){document.loginForm.login.value=document.loginForm.login1.value+'@'+document.loginForm.domain.value;}



function selectname()
{
document.loginForm.login.select()
}


function dologin(form,login_url)
{
	loginname = form.login.value.split("@");
	if(loginname[1])
		form.login.value=loginname[0];
}




function validate_gsearch()

  {
   if(document.gsearch.q.value=="")
   {
    window.alert("Please enter the Keyword");
    document.gsearch.q.focus();
    return false;
   }

   return true;
  }



function parse( )
{
  var regexS = "[\\?&]"+q+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

function popup(p1,p2,p3)
{
 window.open(p1,p2,p3);
}

function activateTab(id, mod, no_tabs) {
    for (var i=1; i<=no_tabs; i++) {
        if  (p_o(mod+"_tc"+i)) {
            if (id == i) {
                p_o(mod+"_tc"+i).style.display = "block";
                p_o(mod+"_t"+i).className= "active";
            } else {
                p_o(mod+"_tc"+i).style.display = "none";
                p_o(mod+"_t"+i).className = "";
            }
        }
    }
}
function p_o(o){return document.getElementById(o);}