var ajax = new sack();
var articleListObj;
var XarticleListObj;
var activeArticle = false;
var clickedArticle = false;
var contentObj	// Reference to article content
var npage;


function showContent()
{   //alert(ajax.response);
	document.getElementById('state').innerHTML = ajax.response;
}

function getstate(country){
 
	ajax.requestFile = "../aboutUs/getstate.php?country="+country;	// Specifying which file to get
	ajax.onCompletion = showContent;	// Specify function that will be executed after file has been found
//	ajax.onLoading = showWaitMessage;	// Action when AJAX is loading the file
	ajax.runAJAX();		// Execute AJAX function	
}


function showstore()
{
 // alert(ajax.response);
  document.getElementById('store').innerHTML = ajax.response;
}


function getstore(state,country){
    // alert("in");
	ajax.requestFile = "../aboutUs/getstore.php?country="+country+"&state="+state;	// Specifying which file to get
	ajax.onCompletion = showstore;	// Specify function that will be executed after file has been found
//	ajax.onLoading = showWaitMessage;	// Action when AJAX is loading the file
	ajax.runAJAX();		// Execute AJAX function	
}

function chk(obj,id)
{  
  if(obj.checked == true)
	{
	  document.getElementById(id).style.display = "block";
	}

	else
	{
		document.getElementById(id).style.display = "none";
	}
}
z
function validate_press()
{
var fname=document.getElementById('fname').value;
var lname=document.getElementById('lname').value;
var email=document.getElementById('email').value;
var remail=document.getElementById('remail').value;
var phone=document.getElementById('phone').value;

if(document.getElementById('fname').value =="")
	{
	alert("Enter First Name"); return false;
	document.getElementById("fname").focus();
  	}

if(document.getElementById('lname').value =="")
	{
	alert("Enter Last Name"); return false;
	document.getElementById("lname").focus();
  	}

if(document.getElementById('username').value =="")
	{
	alert("Enter User Name"); return false;
	document.getElementById("username").focus();
  	}

if(document.getElementById('email').value =="")
	{
	alert("Enter Email"); return false;
	document.getElementById("email").focus();
  	}

echeck(document.getElementById('email').value);

if(document.getElementById('remail').value =="")
	{
	alert("Confirm Email"); return false;
	document.getElementById("remail").focus();
  	}

if(document.getElementById('email').value!=document.getElementById('remail').value)
	{
	alert("Both Email Id's Should Be Same"); return false;
	document.getElementById("remail").focus();
  	}

if(document.getElementById('pwd').value =="")
	{
	alert("Enter Password"); return false;
	document.getElementById("pwd").focus();
  	}
if(document.getElementById('rpwd').value =="")
	{
	alert("Retype your Password"); return false;
	document.getElementById("rpwd").focus();
  	}
if(document.getElementById('pwd').value!=document.getElementById('rpwd').value)
	{
	alert("Both password Should Be Same"); return false;
	document.getElementById("rpwd").focus();
  	}

if(document.getElementById('address').value =="")
	{
	alert("Enter address"); return false;
	document.getElementById("address").focus();
  	}


if(isNaN(parseInt(phone)))
	{
	alert("Enter Phone"); return false;
	document.getElementById("phone").focus();
  	}
	if (!(phone.length == 10)) {
	alert("The phone number is the wrong length"); return false
}

if(document.getElementById('security_code').value =="")
	{
	alert("Enter Security Code"); return false;
	document.getElementById("security_code").focus();
  	}


}

function echeck(str)
{
    	var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid Email ID!");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid Email ID!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
		    alert("Invalid Email ID!");
		    return false;
		}
    	if (str.indexOf(at,(lat+1))!=-1)
		{
		   alert("Invalid Email ID!");
		   return false;
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		   alert("Invalid Email ID!");
		   return false;
		}

		if (str.indexOf(dot,(lat+2))==-1)
		{
		   alert("Invalid Email ID!");
		   return false;
		}
		if (str.indexOf(" ")!=-1)
		{
		   alert("Invalid Email ID!");
		   return false;
		}
		return true;
}

function checknumber(vSTR)
{
    var stripped =vSTR.replace(/([0-9\-\+\.\(\)]+)/,'')
    stripped =stripped.replace(/([0-9\-\+\.\(\)]+)/,'')
    //alert(stripped)
    
    if (isNaN(parseInt(stripped)))
    {
        if(stripped=="")
        {
            testresult=false;
        }
        else
        {
            testresult=true;
        }
    }
    else
    {
        testresult=false;
    }
    return testresult;
}

function getnextdateatopage(maxPage,linksum,linkurl){
	 
	//alert("MaxPage===="+maxPage+' '+"Link sum===="+linksum+' '+"LinkUrl===="+linkurl);
	
	//alert(dateone+'  '+datetwo+'  '+country);
	//alert(maxPage);
	//alert(linkurl+"?"+linksum+"&pageNum="+maxPage);
	ajax.requestFile = linkurl+"?"+linksum+"&pageNum="+maxPage;	// Specifying which file to get
	ajax.onCompletion = EventshowContent;	// Specify function that will be executed after file has been found
	//ajax.onLoading = showallsrcresults;	// Action when AJAX is loading the file
	ajax.onLoading = document.getElementById('showresc').innerHTML  = '<img src="../images/loading.gif" alt="Loading" />';
	ajax.runAJAX();		// Execute AJAX function	
	}

	function EventshowContent(){// Displaying content in the content <div>
 
	document.getElementById('showresc').innerHTML = ajax.response;	// ajax.response is a variable that contains the content of the external file	
}