// JavaScript Document
//######################################33 FRM_CHECK(); ############################3

function frm_check()
{
var a=document.getElementById('name');
if(a.value=='')
alert('Email field is empty');
else
{
email_check(a.value);
document.home.submit();
}

}



//######################################  Coin_count(); ############################3


/*function count_coin()
{
	var shipping=document.getElementById('shipping');
	var ship_charge;
	var getdata=document.getElementById('coin').value;
	document.getElementById('quantity').value=getdata;
	
var rate;

if(getdata>=1 && getdata<=5)
rate=40;
else if(getdata>=6 && getdata<=10)
rate=35;
else if(getdata>=11 && getdata<=20)
rate=30;
else if(getdata>=21 && getdata<=50)
rate=25;
else if(getdata>=51 && getdata<=100)
rate=20;
else if(getdata>=101 && getdata<=500)
rate=18;
else if(getdata>500)
rate=16;
else
rate=0;

if(getdata<=20)
{
ship_charge=4.95;
shipping.style.display='';

}
else
{
ship_charge=0;
shipping.style.display='none';
}



document.getElementById('cost').value=rate;

document.getElementById('total').value=rate*getdata;

if((rate*getdata)>0)
document.getElementById('g_total').innerHTML='USD '+(rate*getdata+ship_charge);
else
document.getElementById('g_total').innerHTML='USD  00.00';


document.checkout.shipping_charge.value=ship_charge;
document.checkout.t_price.value=rate*getdata+ship_charge;
document.checkout.quan.value=getdata;
document.checkout.rt.value=rate;



}*/


//######################################  sendmail(); ############################3

function sendmail()
{
	if(document.contactus.name.value=='')
	{
		alert('Enter your Name');
		return false;
	}
		if(document.contactus.email.value=='')
	{
		alert('Enter your Email');
		return false;
	}
	
	if(document.contactus.phone.value=='')
	{
		alert('Enter your Contact Number');
		return false;
	}
	
	if(document.contactus.message.value=='')
	{
		alert('How did you know about us?');
		return false;
	}
	
	
	document.contactus.submit();
	
}

//######################################  phone_check(); ############################3

function  phone_check(phone)
{
if(isNaN(phone))
{
alert('Phone contains only number');
document.contactus.phone.value='';
}}




function email_check(str)
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   document.contactus.email.value='';
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		 }
		  if (str.substring(lstr-1,lstr)==dot){
		    alert("Invalid E-mail ID");
			document.contactus.email.value='';
		    return false
		 }
		

 		 return true					
	}



//######################################### show_hide(); ################################


function show_hide()
{
	var hid=document.getElementById('second');
	var a=document.getElementById('ship');
	var b=document.getElementById('hold');
if(b.checked)
hid.style.display='';
else
hid.style.display='none';

	
}



function sel(email)
{
document.acc.acc_name.value=email;
con=confirm('Are you sure to make this account default?');
if(con)
document.acc.submit();
else
return false;
}
