// JavaScript Document

var terms = true;

function show_result(z)
{
	document.getElementById('preloader').style.visibility = 'hidden';
    var x = document.getElementById('check');
	
	if(z==1)
	   x.innerHTML="<font color='#FF0000'>Not Available</font>";
	else
	   x.innerHTML="<font color='#A6C052'>Available</font>";
}

function valid_username()
{
   var username=document.getElementById("username").value;
   var submitOK="true";
   
   if(username.length<1)
   {
     alert("Username field can't be blank")
     submitOK="false"
     document.getElementById("username").focus()
     return false
   }
      
   if(submitOK=="false")
     return false
   else
   {	
     while(username.indexOf("+")!=-1)
		   username=username.replace("+","&plus;");
	
	 document.getElementById('preloader').style.visibility = 'visible';
     document.getElementById('preloader').innerHTML = 'Checking ...';
	 x_check_username(username,show_result);
   }
}

function validate()
{
   var username=document.getElementById("username").value;
   var password=document.getElementById("password").value; 
   var confpassword=document.getElementById("confpassword").value;
   var company=document.getElementById("company").value;
   var address=document.getElementById("address").value;
   var country=document.getElementById("country");
   var country1=country.options[country.selectedIndex].text;
   var phone=document.getElementById("phone").value;
   var email=document.getElementById("email").value;
   var email1=document.getElementById("email").value.indexOf("@");
   var person=document.getElementById("person").value;
   var designation=document.getElementById("designation").value;
   var business=document.getElementById("business").value;
   
   submitOK="true";
   
   if(username.length<1)
   {
      alert("Username field can't be blank")
      submitOK="false"
      document.getElementById("username").focus()
      return false
   }
   
   if(password.length<1)
   {
     alert("Password field can't be blank")
     submitOK="false"
     document.getElementById("password").focus()
     return false
   }
   
   if(confpassword.length<1)
   {
     alert("Confirm password field can't be blank")
     submitOK="false"
     document.getElementById("confpassword").focus()
     return false
   }
   
   if(company.length<1)
   {
     alert("Company name field can't be blank")
     submitOK="false"
     document.getElementById("company").focus()
     return false
   }
   
   if(address.length<1)
   {
     alert("Address field can't be blank")
     submitOK="false"
     document.getElementById("address").focus()
     return false
   }
   
   if(!country1.match("Bangladesh"))
   {
	  var city=document.getElementById("city").value; 
	  
	  if(city.length<1)
      {
         alert("City field can't be blank")
         submitOK="false"
         document.getElementById("city").focus()
         return false
      }
   }
   
   if(phone.length<1)
   {
     alert("Phone field can't be blank");
     document.getElementById("phone").focus();
     submitOK="false";
     return false;
   }
   
   if(email.length<1)
   {
     alert("Email field can't be blank");
     document.getElementById("email").focus();
     submitOK="false";
     return false;
   }
 
   if(email1==-1)
   {
     alert("Not a valid e-mail address!");
     document.getElementById("email").focus();
     submitOK="false";
     return false;
   }
   
   if(person.length<1)
   {
     alert("Contact person field can't be blank");
     document.getElementById("person").focus();
     submitOK="false";
     return false;
   }
 
   if(designation.length<1)
   {
     alert("Designation field can't be blank");
     document.getElementById("designation").focus();
     submitOK="false";
     return false;
   }
   
   if(business.length<1)
   {
     alert("Company business field can't be blank");
     document.getElementById("business").focus();
     submitOK="false";
     return false;
   }
   
   if(password!=confpassword)
   {
     alert("Password Can't match");
	 submitOK="false";
	 document.getElementById("confpassword").focus()
     return false;
   }
 
   if(!terms)
   {
     alert("Please accept pricing policy and terms and conditions.");
     submitOK="false";
     return false;
   }
   
   if(submitOK=="false")
      return false
}

function show_city()
{
   var country=document.getElementById("country");
   var country1=country.options[country.selectedIndex].text;
   
   if(country1.match("Bangladesh"))
   {
	  document.getElementById('city_tl').innerHTML = "District";
	  document.getElementById('sp_city').innerHTML = "<select name='city' id='city' style='width:160px;' class='dropdown'><option>B. Baria</option><option>Bagerhat</option><option>Bandarban</option><option>Barisal</option><option>Bhola</option><option>Bogra</option><option>Borguna</option><option>Chandpur</option><option>Chapainawabganj</option><option>Chittagong</option><option>Chuadanga</option><option>Comilla</option><option>Cox's Bazar</option><option selected='selected'>Dhaka</option><option>Dinajpur</option><option>Faridpur</option><option>Feni</option><option>Gaibandha</option><option>Gazipur</option><option>Gopalgonj</option><option>Hobigonj</option><option>Jamalpur</option><option>Jessore</option><option>Jhalokathi</option><option>Jhenaidah</option><option>Joypurhat</option><option>Khagrachari</option><option>Khulna</option><option>Kishorgonj</option><option>Kurigram</option><option>Kushtia</option><option>Lalmonirhat</option><option>Laxmipur</option><option>Madaripur</option><option>Magura</option><option>Manikgonj</option><option>Meherpur</option><option>MoulaviBazar</option><option>Munshigonj</option><option>Mymensingh</option><option>Naogaon</option><option>Narail</option><option>Narayangonj</option><option>Narshingdi</option><option>Natore</option><option>Netrokona</option><option>Nilphamari</option><option>Noakhali</option><option>Pabna</option><option>Panchagahr</option><option>Patuakhali</option><option>Pirojpur</option><option>Rajbari</option><option>Rajshahi</option><option>Rangamati</option><option>Rangpur</option><option>Satkhira</option><option>Shariatpur</option><option>Sherpur</option><option>Sirajgonj</option><option>Sunamgonj</option><option>Sylhet</option><option>Tangail</option><option>Thakurgaon</option></select> <font color='#FF0000'>*</font>";
   }
   else
   {
      document.getElementById('city_tl').innerHTML = "City";
	  document.getElementById('sp_city').innerHTML = "<input class='textbox' name='city' id='city' type='text' style='width:160px;' /> <font color='#FF0000'>*</font>";
   }
}

function check(value)
{
    terms = value; 
}

function is_loaded()
{ //DOM
	if(document.getElementById)
	{
	   document.getElementById('preloader').style.visibility = 'hidden';
	   document.getElementById('chakri_ad_content').style.visibility = 'visible';
	   //document.getElementById('main_content').style.visibility = 'visible';
	}
	else
	{
		if(document.layers)
		{
		   document.preloader.visibility = 'hidden';
		   document.chakri_ad_content.visibility = 'visible';
		   //document.main_content.visibility = 'visible';
		}
		else
		{
		   document.all.preloader.style.visibility = 'hidden';
		   document.all.chakri_ad_content.style.visibility = 'visible';
		   //document.all.main_content.style.visibility = 'visible';
		}  
	}
}
