
///////////////////////////////////////////////////////////////////////////

var url,zsign;
var xmlHttpSunSignDaily,xmlHttpSunSignWeekly;
var xmlHttpMoonSignDaily,xmlHttpMoonSignWeekly;
//global declarations


function getsunsignprediction(Zsign,_params,fscope)
{
  
   //zsign=Zsign;
   pagename=zsign.toLowerCase()+"-sign.php"
   url=pagename+'?RequestType=Short&'+_params;
   
  if (fscope=='Daily')
    process('sunsign-daily');
  
  else if (fscope=='Weekly')
  	process('sunsign-weekly');
    
}


function getmoonsignprediction(Zsign,_params,fscope)
{
  
  //zsign=Zsign;
  pagename="rashi-prediction.php"
  url=pagename+'?RequestType=Short&'+_params;
  //alert(fscope+url);
  if (fscope=="Daily")
  	process('moonsign-daily'); 
  else if (fscope=="Weekly") 
    process('moonsign-weekly'); 
}



///////////////////////////////////////////////////////////////////////////
// retrieves the XMLHttpRequest object

function createXmlHttpRequestObject()
{
var reqHttp;
if(window.ActiveXObject)
{
	try
	{
		reqHttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	}
	catch (e)
	{
		reqHttp = false;
	}
}
// if running Mozilla or other browsers
else
{
	try
	{
		reqHttp = new XMLHttpRequest();
		
	}
	catch (e)
	{
		reqHttp = false;
	}
}
if (!reqHttp)
	alert("Error creating the XMLHttpRequest object.");
else
	return reqHttp;
}
//////////////////////////////////////////////////////////////////////

function process(sType)
{
    //alert('inside process'+sType);
	
	if ( sType=='sunsign-daily')
	{
		xmlHttpSunSignDaily = createXmlHttpRequestObject();
		// proceed only if the xmlHttp object isn't busy

		if (xmlHttpSunSignDaily.readyState == 4 || xmlHttpSunSignDaily.readyState == 0)
		{
			xmlHttpSunSignDaily.open("GET",url,true);
			
			xmlHttpSunSignDaily.onreadystatechange = handleServerResponseForSunSignDaily;
			xmlHttpSunSignDaily.send(null);
	
		}
		else
		{
		// if the connection is busy, try again after one second
 		t = setTimeout('process()', 1000);
		}
	}


		if ( sType=='sunsign-weekly')
	    {
			xmlHttpSunSignWeekly = createXmlHttpRequestObject();
			// proceed only if the xmlHttp object isn't busy
			//alert('inside process');
			if (xmlHttpSunSignWeekly.readyState == 4 || xmlHttpSunSignWeekly.readyState == 0)
			{
			xmlHttpSunSignWeekly.open("GET",url,true);
			
			xmlHttpSunSignWeekly.onreadystatechange = handleServerResponseForSunSignWeekly;
			xmlHttpSunSignWeekly.send(null);
	
			}
			else
			{
			// if the connection is busy, try again after one second
 			t = setTimeout('process()', 1000);
			}
		}


	
	
	
	
	
	else if ( sType=='moonsign-daily')
	{
		xmlHttpMoonSignDaily = createXmlHttpRequestObject();
		// proceed only if the xmlHttp object isn't busy

		if (xmlHttpMoonSignDaily.readyState == 4 || xmlHttpMoonSignDaily.readyState == 0)
		{
		xmlHttpMoonSignDaily.open("GET",url,true);
		
		xmlHttpMoonSignDaily.onreadystatechange = handleServerResponseForMoonSignDaily;
		xmlHttpMoonSignDaily.send(null);
	
		}
		else
		{
		// if the connection is busy, try again after one second
 		t = setTimeout('process()', 1000);
		}
	}


	else if ( sType=='moonsign-weekly')
	    {
			xmlHttpMoonSignWeekly = createXmlHttpRequestObject();
			// proceed only if the xmlHttp object isn't busy
			//alert('inside process');
			if (xmlHttpMoonSignWeekly.readyState == 4 || xmlHttpMoonSignWeekly.readyState == 0)
			{
			xmlHttpMoonSignWeekly.open("GET",url,true);
			
			xmlHttpMoonSignWeekly.onreadystatechange = handleServerResponseForMoonSignWeekly;
			xmlHttpMoonSignWeekly.send(null);
	
			}
			else
			{
			// if the connection is busy, try again after one second
 			t = setTimeout('process()', 1000);
			}
		}



}
// executed automatically when a message is received from the server
function handleServerResponseForMoonSignDaily()
{
	//alert('handle');
	
				if (xmlHttpMoonSignDaily.readyState == 4)
	            {
                  // status of 200 indicates the transaction completed successfully
		                 if (xmlHttpMoonSignDaily.status == 200)
		                   {
		
			                       _dataMoonSignDaily='<b class="fnt14">'+GetStarName(document.getElementById("dRasi").value,'Indian')+' :</b>' ;
			                       _dataMoonSignDaily =  _dataMoonSignDaily + xmlHttpMoonSignDaily.responseText;
	    	                        document.getElementById("moonsigndaily").innerHTML  = _dataMoonSignDaily;
									
		                    }
                            // a HTTP status different than 200 signals an error
	             }
	             else
	           {
		                     document.getElementById("moonsigndaily").innerHTML  = '' ;
	           }
	
 }
 
 function handleServerResponseForMoonSignWeekly()
{
	//alert('handle');
	
				if (xmlHttpMoonSignWeekly.readyState == 4)
	            {
                  // status of 200 indicates the transaction completed successfully
		                 if (xmlHttpMoonSignWeekly.status == 200)
		                   {
									//alert('inside handle');
			                       _dataMoonSignWeekly='<b class="fnt14">'+GetStarName(document.getElementById("wRasi").value,'Indian')+' :</b>' ;
			                       _dataMoonSignWeekly =  _dataMoonSignWeekly + xmlHttpMoonSignWeekly.responseText;
	    	                        document.getElementById("moonsignweekly").innerHTML  = _dataMoonSignWeekly;
									//alert(_dataMoonSignWeekly);
		                    }
                            // a HTTP status different than 200 signals an error
	             }
	             else
	           {
		                     document.getElementById("moonsignweekly").innerHTML  = '' ;
	           }
	
 }


function handleServerResponseForSunSignDaily()
{
	//alert('handle');
	
				if (xmlHttpSunSignDaily.readyState == 4)
	            {
                  // status of 200 indicates the transaction completed successfully
		                 if (xmlHttpSunSignDaily.status == 200)
		                   {
		
			                       _dataSunSignDaily='<b class="fnt14">'+GetStarName(document.getElementById("dZodiac").value,'Western')+' :</b>' ;
			                       _dataSunSignDaily =  _dataSunSignDaily + xmlHttpSunSignDaily.responseText;
	    	                        document.getElementById("sunsigndaily").innerHTML  = _dataSunSignDaily;
									
		                    }
                            // a HTTP status different than 200 signals an error
	             }
	             else
	           {
		                     document.getElementById("sunsigndaily").innerHTML  = '' ;
	           }
	
 }
 
 function handleServerResponseForSunSignWeekly()
{
	//alert('handle');
	
				if (xmlHttpSunSignWeekly.readyState == 4)
	            {
                  // status of 200 indicates the transaction completed successfully
		                 if (xmlHttpSunSignWeekly.status == 200)
		                   {
									//alert('inside handle');
			                       _dataSunSignWeekly='<b class="fnt14">'+GetStarName(document.getElementById("wZodiac").value,'Western')+' :</b>' ;
			                       _dataSunSignWeekly =  _dataSunSignWeekly + xmlHttpSunSignWeekly.responseText;
	    	                        document.getElementById("sunsignweekly").innerHTML  = _dataSunSignWeekly;
									//alert(_dataSunSignWeekly);
		                    }
                            // a HTTP status different than 200 signals an error
	             }
	             else
	           {
		                     document.getElementById("sunsignweekly").innerHTML  = '' ;
	           }
	
 }


//copied from astrofuncs.js
function LoveMatchRedirect() { 

	var strUrl=""

	
	var strPzodiac=window.document.forms["formLoveMatch"].LmPZodiac.options[window.document.forms["formLoveMatch"].LmPZodiac.selectedIndex].value

    strUrl=strUrl + strPzodiac.substring(0,3)         // Adding first 3 chars of persons zodiac name

	var strLzodiac=window.document.forms["formLoveMatch"].LmLZodiac.options[window.document.forms["formLoveMatch"].LmLZodiac.selectedIndex].value

    strUrl=strUrl + strLzodiac.substring(0,3)         // Adding first 3 chars of lovers zodiac name

	strUrl=strUrl + ".htm"

	if (strPzodiac != strLzodiac) {  //If the Zodiac Signs are same, no need to consider sex

			if (window.document.formLoveMatch.LmSex[0].checked == true) {

			 strUrl="m" + strUrl 		}  //male

			else {

			 strUrl="f" + strUrl 	} }		// female 


	strUrl="western-astrology/lovematch/" + strUrl


	window.open(strUrl,"","toolbar=no,directories=no,resize=no,menubar=no,location=no,scrollbars=yes,width=626,height=400, maximize=null");
return true;
}
function setSubmitionDate()

{

       var todayDate,thisday,thismonth,thisyear,strPassDate,thisdate

       var thishour,thisminute,thissecond

	todayDate=new Date()

	thisday=(todayDate.getDay()+1)

	thismonth=(todayDate.getMonth()+1)

	 if (thismonth<10)

	 {

          thismonth="0"+thismonth

         }

	 thisdate=todayDate.getDate()

	 if (thisdate<10)

	 {

          thisdate="0"+thisdate

         }

	thisyear=todayDate.getYear()

        if(thisyear<1000){

        	thisyear+=1900

        }

	strPassDate = thisyear.toString()+thismonth.toString()+thisdate.toString()+thisday.toString()



	thishour = todayDate.getHours()

	thisminute = todayDate.getMinutes()

	thissecond = todayDate.getSeconds()

	
 return (strPassDate);
}

function submitFromIndian(){	
if (window.document.formForecastIndian.zodiac.value!=0)
{


window.document.formForecastIndian.SubmissionDate.value= setSubmitionDate();


if (window.document.formForecastIndian.forecastscope[0].checked)

     fscope=window.document.formForecastIndian.forecastscope[0].value

else

     fscope=window.document.formForecastIndian.forecastscope[1].value

data=window.document.formForecastIndian.ForecastStyle.value+","+

window.document.formForecastIndian.zodiac.value+","+

window.document.formForecastIndian.SubmissionDate.value+","+

 fscope


window.document.formForecastIndian.forecastscope[0].focus()
window.open("common/daily-weekly-prediction.php?data="+data);
}
else
	{
	alert("Select your birth sign")
		return;
	}
}

function submitFromWestern(){	
	if (window.document.formForecastWestern.zodiac.value!=0)
	{


	window.document.formForecastWestern.SubmissionDate.value=setSubmitionDate();

if (window.document.formForecastWestern.forecastscope[0].checked)

     fscope=window.document.formForecastWestern.forecastscope[0].value

else

     fscope=window.document.formForecastWestern.forecastscope[1].value

data=window.document.formForecastWestern.ForecastStyle.value+","+

window.document.formForecastWestern.zodiac.value+","+

window.document.formForecastWestern.SubmissionDate.value+","+

 fscope


window.document.formForecastWestern.forecastscope[0].focus()
window.open("common/daily-weekly-prediction.php?data="+data);

	}
	else
	{
	alert("Select your birth sign")
		return;
	}
}


function submitFromImageIndian(ImageNumber){

 window.document.formForecastIndian.SubmissionDate.value=setSubmitionDate();
 window.document.formForecastIndian.Zodiac.value=ImageNumber.toString()
 window.document.formForecastIndian.action="http://202.146.195.130/script/nasAVForecast.exe";
 document.formForecastIndian.submit();
}








function GetStarName(strVal,fstyle)
{
	if (fstyle =="Western")
	{
		switch(strVal)
						{
							case '01':
											return 'Aries';
											break;
							case '02':
											return 'Taurus';
											break;
							case '03':
											return 'Gemini';
											break;
							case '04':
											return 'Cancer';
											break;
							case '05':
											return 'Leo';
											break;
							case '06':
											return 'Virgo';
											break;
							case '07':
											return 'Libra';
											break;
							case '08':
											return 'Scorpio';
											break;
							case '09':
											return 'Sagittarius';
											break;
							case '10':
											return 'Capricon';
											break;
							case '11':
											return 'Aquarius';
											break;
							case '12':
											return 'Pisces';
											break;
						}
		}
		else if(fstyle =="Indian")
			{
				switch(strVal)
				{
					case '01':
									return 'Mesha';
									break;
					case '02':
									return 'Vrishabha';
									break;
					case '03':
									return 'Mithuna';
									break;
					case '04':
									return 'Karkata';
									break;
					case '05':
									return 'Simha';
									break;
					case '06':
									return 'Kanya';
									break;
					case '07':
									return 'Thula';
									break;
					case '08':
									return 'Vrischika';
									break;
					case '09':
									return 'Dhanu';
									break;
					case '10':
									return 'Makara';
									break;
					case '11':
									return 'Kumbha';
									break;
					case '12':
									return 'Meena';
									break;
				}//switch	
			}	//if		
	} //fun
	
	//from misc.js
	function tlmm(id1,id2,id3,id4,id5,id6,id7,id8){
	document.getElementById(id1).className = "tlmmact";	
	document.getElementById(id2).className = "tlmm";	
	document.getElementById(id3).className = "tlmm";	
	document.getElementById(id4).className = "tlmm";
	document.getElementById(id5).style.display = "block";	
	document.getElementById(id6).style.display = "none";
	document.getElementById(id7).style.display = "none";
	document.getElementById(id8).style.display = "none";
}

function lfwd(id1,id2,id3,id4,id5,id6,id7,id8){
	document.getElementById(id1).className = "lfwdact";	
	document.getElementById(id2).className = "lfwd";	
	document.getElementById(id3).className = "lfwd";	
	document.getElementById(id4).className = "lfwd";
	document.getElementById(id5).style.display = "block";	
	document.getElementById(id6).style.display = "none";
	document.getElementById(id7).style.display = "none";
	document.getElementById(id8).style.display = "none";
}

function subnav(id1,id2,id3,id4,id5,id6){
	document.getElementById(id1).style.display = "block";	
	document.getElementById(id2).style.display = "none";
	document.getElementById(id3).style.display = "none";
	document.getElementById(id4).style.display = "none";
	document.getElementById(id5).style.display = "none";
	document.getElementById(id6).style.display = "none";
}

function subnav1(id1,id2,id3,id4,id5,id6){
	document.getElementById(id1).className = "active";		
	document.getElementById(id2).className = "tplinks";
	document.getElementById(id3).className = "tplinks";
	document.getElementById(id4).className = "tplinks";
	document.getElementById(id5).className = "tplinks";
	document.getElementById(id6).className = "tplinks";
}

//from index page
function sunsign(zodiacsign,fscope)
{
   //alert('sunsign');
   zsign=GetStarName(zodiacsign,'Western');
   //alert('zodiac'+zsign);
   if (fscope=='Daily') 
   {
	document.getElementById("sunsignimgdaily").innerHTML  ='<img src="image/icons/BB_icon_'+zsign+'.gif">';
	document.getElementById("dZodiac").value=zodiacsign;
	
	}
   else if (fscope=='Weekly') 
   {
	document.getElementById("sunsignimgweekly").innerHTML  ='<img src="image/icons/BB_icon_'+zsign+'.gif">';
	document.getElementById("wZodiac").value=zodiacsign;
	 
   }		
	 sDate=setSubmitionDate();
	//neebr alert('sdate'+sDate);
	getsunsignprediction(zsign,"SubmissionDate="+sDate+"&forecastscope="+fscope+"&ForecastStyle=Western",fscope);

}

function moonsign(zodiacsign,fscope)
{
   zsign=GetStarName(zodiacsign,'Western');
   if (fscope=='Daily') 
   {
	document.getElementById("moonsignimgdaily").innerHTML  ='<img src="image/icons/BB_icon_'+zsign+'.gif">';
	document.getElementById("dRasi").value=zodiacsign;
	
	}
   else if (fscope=='Weekly') 
   {
	document.getElementById("moonsignimgweekly").innerHTML  ='<img src="image/icons/BB_icon_'+zsign+'.gif">';
	document.getElementById("wRasi").value=zodiacsign;
	
   }		
	 sDate=setSubmitionDate();
	 zsign=GetStarName(zodiacsign,'Indian');
	getmoonsignprediction(zsign,"SubmissionDate="+sDate+"&forecastscope="+fscope+"&ForecastStyle=Indian&Zodiac="+zodiacsign,fscope);

}

function submitformForecastWesternWeekly(){	//Anil20010514
	sDate=setSubmitionDate();
    document.frmForecastWesternWeekly.SubmissionDate.value=sDate;
    ZNumber=document.frmForecastWesternWeekly.wZodiac.value;
   		
	document.frmForecastWesternWeekly.action=GetStarName(ZNumber,'Western').toLowerCase()+"-sign.php";
    document.frmForecastWesternWeekly.submit()
 
}
function submitformForecastWesternDaily(){	//Anil20010514
	sDate=setSubmitionDate();
    document.frmForecastWesternDaily.SubmissionDate.value=sDate;
    ZNumber=document.frmForecastWesternDaily.dZodiac.value;
   		
	document.frmForecastWesternDaily.action=GetStarName(ZNumber,'Western').toLowerCase()+"-sign.php";
    document.frmForecastWesternDaily.submit()
 
}
function submitformForecastIndianWeekly(){	//Anil20010514
	sDate=setSubmitionDate();
    document.frmForecastIndianWeekly.SubmissionDate.value=sDate;
    		
	document.frmForecastIndianWeekly.action="rashi-prediction.php";
    document.frmForecastIndianWeekly.submit()
 
}
function submitformForecastIndianDaily(){	//Anil20010514
	sDate=setSubmitionDate();
    document.frmForecastIndianDaily.SubmissionDate.value=sDate;
      		
	document.frmForecastIndianDaily.action="rashi-prediction.php";
    document.frmForecastIndianDaily.submit()
 
}
function intializethepage()
{
	sunsign('01','Daily');
	sunsign('01','Weekly'); 
	moonsign('01','Daily');
	moonsign('01','Weekly');

}
