function check_all_tlds(tld_amount) {
  for(var i=1;i<= tld_amount;i++) {
     var check_tld = document.getElementById('dot'+i);
     check_tld.checked = document.registration.select_all.checked;
        
  }
}

function validate_add_balance() {
	if(is_null(document.add_balance_form.add_amount.value)) {
		alert("Please enter the amount to be add");
		document.add_balance_form.add_amount.focus();
	   return false;
	}
   if(!is_numeric(document.add_balance_form.add_amount.value)) {
	   alert("Amount must be a numeric number");
		document.add_balance_form.add_amount.focus();
		return false;
	}	
	if(is_null(document.getElementById('cc_name').value)) {
		alert("Please enter the Cardholder Name");
		document.getElementById('cc_name').focus();
	   return false;
	}
	if(is_null(document.getElementById('cc_number').value)) {
		alert("Please enter the Card Number");
		document.getElementById('cc_number').focus();
	   return false;
	}
	if(is_null(document.getElementById('cc_code').value)) {
		alert("Please enter the Card Verification Number");
		document.getElementById('cc_code').focus();
	   return false;
	}
	if(is_null(document.getElementById('address1').value)) {
		alert("Please enter the Cardholder's Address");
		document.getElementById('address1').focus();
	   return false;
	}
	if(is_null(document.getElementById('first_name').value)) {
		alert("Please enter the Cardholder's First Name");
		document.getElementById('first_name').focus();
	   return false;
	}
	if(is_null(document.getElementById('last_name').value)) {
		alert("Please enter the Cardholder's Last Name");
		document.getElementById('last_name').focus();
	   return false;
	}
	if(is_null(document.getElementById('city').value)) {
		alert("Please enter the Cardholder's city");
		document.getElementById('city').focus();
	   return false;
	}
	if(is_null(document.getElementById('zip').value)) {
		alert("Please enter the Cardholder's Zip");
		document.getElementById('zip').focus();
	   return false;
	}
	if(is_null(document.getElementById('country').value)) {
		alert("Please select Cardholder's country");
	   return false;
	}
	if(is_null(document.getElementById('phone').value)) {
		alert("Please enter the Cardholder's phone");
		document.getElementById('phone').focus();
	   return false;
	}
	document.add_balance_form.add_balance.disabled = true;
	document.add_balance_form.submit();
}
function display_vat(selected_country){
	var pay_vat_country = ["FR","LT","SE","MT","IE","IT","CZ" ,"BE","LU","GR","MC","DE","SK","SI","AT","CY","GB","HU","DK","ES","EE","NL","FI","PL","PT"];
		row = document.getElementById('vat_number_row');
		var found = 0
		for(i=0;i< pay_vat_country.length;i++)
		   if(pay_vat_country[i] == selected_country)
		      found =1
		if (found > 0) 
			row.style.display = '';
		else 
			row.style.display = 'none';			 
}
function restore_domain(domain) {
	var answer = confirm ("Are you sure you want to restore "+domain);
	if(answer) {
	   document.restore_domain_form.submit();
	}
}
function add_fund_check(type) {
	var add_amount = document.getElementById(type+'_addamount').value;
	
   if(!is_numeric(add_amount)) {
	   alert("Please enter a valid Number");
		document.getElementById(type+'_addamount').focus();
	   return ;
	}	
	
	document.add_balance_form.pay_via_cc.disabled=true;
	document.add_balance_form.submit();
}
function is_numeric(number){
        
        var regex = /(^\d+$)|(^\d+\.\d+$)|(^[\d.]*$)/;

	
        if (regex.test(number)){
                return true;
        }
        return false;
}

function show_pay_option_detaisl(show_id) {
   var ids = Array("paypal_row","cc_row","wire_transfer_row"); 
   var row= document.getElementById(show_id);
	row.style.display='';
	for (var x in ids){
	   if(ids[x] != show_id) {
			row= document.getElementById(ids[x]);
			if(row) {
			row.style.display='none';	
			}
		}

	}
}
function view_registrant_contact_details(contact_identifyer,event,a_object) {
	
 	fixedtooltip("<div style='text-align:center;padding:10px;'>Loading...<br/><img src='../img/loading.gif' /><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></div>", a_object, event, '270px' ); 
 
	setTimeout(
		function() {
			display_contact_details(contact_identifyer,event,a_object);
		}
	,1);
		
		 
}

function view_default_setting_contact_by_field(field_id,event,a_object) {
   var field_val = document.getElementById(field_id);
   view_registrant_contact_details(field_val.value,event,a_object);
}

function display_contact_details(contact_identifyer,event,a_object) {
	var content = '';
	$.ajax({ 
			url: "get_contact_details_by_contact_idetifiery.html?dont_render_template=1&contact_identifyer="+contact_identifyer,	
			timeout: 30000,
			cache:false ,
			success:function(msg){ 
				 fixedtooltip(msg, a_object, event, '270px' );
 				
			}
		} );
		
}

function confirm_all_domain() {  
	var on_off = document.transfer_confirm_form.checkall.checked;
  for(var i = 0; i< document.getElementsByTagName("input").length;i++) {
		 var input_box = document.getElementsByTagName("input")[i];
		 if(input_box.type == 'checkbox'  ) {
			 input_box.checked= on_off;
		}
  }
}

function validate_transfer_confirm_form() {     
  if(document.transfer_confirm_form.confirm_code.value == '') {
      alert("Please insert Security Code");
		document.transfer_confirm_form.confirm_code.focus();
		return;
  }
  document.transfer_confirm_form.submit();
}
function advance_search_option(hide) {
	var arr=["search_option_username","search_option_create","search_option_expires","search_option_dns1","search_option_dns2","search_option_match","search_option_status","search_option_expired"];  
	var search_option_link = document.getElementById('search_option_link');
	var option_values =["DomStatus","txtMatches","txtdns2","txtdns1","txtExpiresWithin","txtCreatedWithin","txtusername","chkExpDomains"]; 

	for(var i=0;i<arr.length;i++) {
		var row = document.getElementById(arr[i]);
		if(row) {
			if (row.style.display == '')  {
			   row.style.display = 'none';
			   search_option_link.innerHTML='Advanced Search';
			  
			    for(var j=0;j<option_values.length;j++) {
				   var row2 = document.getElementsByName(option_values[j]);
				   if(typeof(row2[0]) != "undefined") {
				     row2[0].value = '';
					 row2[0].checked = false;
				   }
			    }	
			}
			else { 

			   row.style.display = '';
			   search_option_link.innerHTML='Basic Search';
			}
		}
	}
}

function validate_contact_form(){
   if(document.domain_contact_form.name.value=='') {
      alert("Please enter your name");
	  return false;
   }
	if (! email_check(document.domain_contact_form.email.value)) {
        alert('Wrong e-mail address format');
        return false;
   }
 
   if(document.domain_contact_form.phone_cc.value=='') {
      alert("Please select phone international prefix");
	  return false;
   }
   if(document.domain_contact_form.phone.value=='') {
      alert("Please enter your phone number");
	  return false;
   }
	else {
	     var regex = /(^\d+$)/;
        if (regex.test(document.domain_contact_form.phone.value) == false){
			  alert("Phone number must be numeric");
             return false;
        }
	}
   if(document.domain_contact_form.address.value=='') {
      alert("Please enter your address");
	  return false;
   }
   if(document.domain_contact_form.city.value=='') {
      alert("Please enter your city");
	  return false;
   }
   if(document.domain_contact_form.state.value=='') {
      alert("Please enter your state");
	  return false;
   }
   if(document.domain_contact_form.postcode.value=='') {
      alert("Please enter your postcode");
	  return false;
   }
   if(document.domain_contact_form.country.value=='') {
      alert("Please select your country");
	  return false;
   }

   document.domain_contact_form.submit();
}
function update_domain_contact_id(domain,contact_id,contact_type) {
   $.ajax({ url: "update_domain_contact_id.html?dont_render_template=1&domain="+domain+"&contact_id="+contact_id+"&contact_type="+contact_type,	timeout: 30000,error: function(request,error) {if(error=='timeout') {  update_domain_contact_id(domain,contact_id,contact_type);   }}, cache:false ,success:function(msg){ alert(msg);}} );
}
function update_domain_contact(action,type,contact_id) {
	if(contact_id != '') {
		x = document.getElementById(contact_id);
		contact_id = x.value; 
	}
	$.ajax({ url: "get_domain_contact_form.html?dont_render_template=1&action="+action+"&type="+type+"&contact_id="+contact_id,	timeout: 30000,error: function(request,error) {if(error=='timeout') {  update_domain_contact(action,type,contact_id);   }}, cache:false ,success:function(msg){ document.getElementById('domain_contact_detail').innerHTML = msg;}} );
}

function showMenu(comId)
{
	x = document.getElementById(comId);
	chkmouseover(comId);
	for(i=0;i<document.forms.length;i++)
	{
		var theForm = document.forms[0];
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one')
				theForm.elements[p].style.display = 'none';
		}
	}
	return true;
}
function  confirm_clear_cart_domain() {
   var answer = confirm ("Are you sure you want to remove ALL domains from your shopping cart?");
   document.shopping_cart_form.action.value='Clear Cart';
   if (answer)
      document.shopping_cart_form.submit();
   
}

function  confirm_delete_cart_domain() {
   var answer = confirm ("Are you sure you want to remove these domains from your shopping cart?");
   document.shopping_cart_form.action.value='Delete';
   if (answer)
      document.shopping_cart_form.submit();
   
}


function checking_update_user() {
   if(document.update_account_detail_form.first_name.value=='') {
      alert("First Name can not be empty!");
	  return;
   }
    if(document.update_account_detail_form.last_name.value=='') {
      alert("Last Name can not be empty!");
	  return;
   }
    if (! email_check(document.update_account_detail_form.email.value)) {
        alert('Wrong e-mail address format');
        return false;
    }
 
    if(document.update_account_detail_form.address.value=='') {
      alert("Street can not be empty!");
	  return;
   }
    if(document.update_account_detail_form.city.value=='') {
      alert("City can not be empty!");
	  return;
   }
    if(document.update_account_detail_form.postcode.value=='') {
      alert("Zip can not be empty!");
	  return;
   }
    if(document.update_account_detail_form.phone.value=='') {
      alert("Phone can not be empty!");
	  return;
   }
    if(document.update_account_detail_form.first_name.value=='') {
      alert("First Name can not be empty!");
	  return;
   }
   document.update_account_detail_form.submit();
 
}

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){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function hideMenu(comId)
{
	x = document.getElementById(comId);

	chkmouseout(comId);
	for(i=0;i<document.forms.length;i++)
	{
		var theForm = document.forms[0];
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one')
				theForm.elements[p].style.display = '';
		}
	}
	return true;
}

function chkmouseover(passobj)
{
	x = document.getElementById(passobj);
	curX = findPosX(x);
	curY = findPosY(x);
	//alert("curX " + curX);
	//alert("curY " + curY);

	y = document.getElementById('menu' + passobj);

	y.style.display = '';

	if(passobj == 'catmenu' || passobj == 'supportmenu' || passobj == 'actcatmenu' || passobj == 'actsupportmenu')
	{
		if(navigator.appName == 'Microsoft Internet Explorer')
		{
			y.style.top = curY + 108;
			y.style.left = curX - 222;
		}
		else
		{
			y.style.top = (curY + 1) + "px";
			y.style.left = (curX - 222) + "px";
		}
	}
	else
	{
		if(navigator.appName == 'Microsoft Internet Explorer')
		{
			y.style.top = curY + 49;
			y.style.left = curX - 1;
		}
		else
		{
			y.style.top = (curY + 49) + "px";
			y.style.left = (curX + 0) + "px";
		}
	}
	//alert(y.style.top);
	//alert(y.style.left);
}

function chkmouseout(passobj)
{
	y = document.getElementById('menu' + passobj);

	y.style.display = 'none';
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function screenWidth()
{
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return frameWidth;
}



function screenHeight()
{
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return frameHeight;
}

function noOfRecChanged(frm)
{
	//alert(location.protocol + "://" + location.host + location.port + location.port + location.pathname);
	
	//var urlstr = location.protocol + "//" + location.host + location.port + location.port + location.pathname;
	//window.location = urlstr + '?recchange='+comval;
	frm.submit();
	return true;
}

function checkUncheckAll(theElement) {
     
     for(var i = 0; i< document.getElementsByTagName("input").length;i++) {
          var check_box = document.getElementsByTagName("input")[i];
          if(check_box.type == 'checkbox' && check_box.name.match("select")) {
               if(document.getElementById('chkAll').checked == true && check_box.disabled != true) {
               		check_box.checked = true;
               } else {
               		check_box.checked = false;
               }
         }
     }
}

function ChkUncheckBoxes(frm)
{   
	var passtype = frm.chkAll.checked;
	var noof = frm.totalrec.value;
	var comobj;
	
	if(passtype == true)
	comclass = "checked";
	else
	comclass = "notchecked";
	
	for(i=0;i<noof;i++)
	{
		//alert(eval("frm.chk_" + i + ".checked"));
		eval("frm.chk_" + i + ".checked = " + passtype);
		x = document.getElementById("tr_" + i);
		//x.className = comclass;
	}
	return true;
}

function ChkUncheckIndBoxes()
{
	return true;
}

function passCheckVariables(frm)
{
	var chkform = document.frmChange;
	var noof = chkform.totalrec.value;
	
	var tmpcnt = 0;
	for(i=0;i<noof;i++)
	{
		comcheckstatus = eval("chkform.chk_" + i + ".checked");
		
		if(comcheckstatus == true)
		{
			if(tmpcnt == 0)
				frm.hidSelectedIDs.value += eval("chkform.chk_" + i + ".value");
			else
				frm.hidSelectedIDs.value += "\r\n" + eval("chkform.chk_" + i + ".value");
			
			tmpcnt++;
		}
	}
	//alert(frm.hidGivenNames.value);
	return true;
}

function trOver(passid)
{
	obj = document.getElementById(passid);

	rows = document.getElementById(passid).getElementsByTagName("td");
	for(i=0;i<rows.length;i++)
	{
		tdobj = rows[i];
		tdobj.style.background='#D2DAFF';
	}
	return true;
}

function trOut(passid)
{
	obj = document.getElementById(passid);
	rows = document.getElementById(passid).getElementsByTagName("td");
	for(i=0;i<rows.length;i++)
	{
		tdobj = rows[i];
		if(tdobj.className == 'shortTD')
		tdobj.style.background='#F0F0F0';
		else
		tdobj.style.background='';
	}
	return true;
}


function chkmouseover(baseid,newid,selectid)
{
	x = document.getElementById(baseid);
	curX = findPosX(x);
	curY = findPosY(x);

	
	//for(i=0;i<document.forms.length;i++)
	//{
		//var theForm = document.forms[i];
		//var theForm = document.frmQuickUpdForm;
		if(selectid == 'txtIntStatusUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		document.getElementById('slFlagUpd').style.display = 'none';
		document.getElementById('slGenericUpd').style.display = 'none';
		}
		else if(selectid == 'slGenericUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		document.getElementById('slFlagUpd').style.display = 'none';
		}
		else if(selectid == 'slFlagUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		}
		
		
	//}
	//alert("curX " + curX);
	//alert("curY " + curY);
	y = document.getElementById(newid);
	y.style.display = '';

	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		y.style.top = curY + 20;
		y.style.left = curX;
	}
	else
	{
		y.style.top = (curY) + 20 + "px";
		y.style.left = (curX) + "px";
	}
	return true;
}

function chSelValue(divid,selectid,selind)
{
	var frm = document.frmQuickUpdForm;
	eval("frm." + selectid + ".options[" + selind + "].selected = true");
	return showHideSelDiv(divid,selectid);
}

function showHideSelDiv(divid,selectid)
{
	d = document.getElementById(divid);
	curdis = d.style.display;

	if(curdis == '')
	{
		d.style.display = 'none';
		var theForm = document.frmQuickUpdForm;
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one' && theForm.elements[p].name != selectid)
				theForm.elements[p].style.display = '';
		}
	}
	else
	{
		d.style.display = '';
		chkmouseover(selectid,divid,selectid);
	}
	return true;
}

function clickEventHand(evt)
{
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		var comid = evt.srcElement;
	}
	else
	{
		var comid = evt.target;
	}
	
	var nohidding = 0;
	if(comid.parentNode)
	{
		if(comid.parentNode.id == 'closedivlink')
		nohidding = 1;
	}
	//if(comid.id == 'GenStatusDiv' ||
	if(!nohidding)
	{
		document.getElementById('GenStatusDiv').style.display = 'none';
		document.getElementById('IntStatusDiv').style.display = 'none';
		document.getElementById('FlagDiv').style.display = 'none';
		document.getElementById('LegStatusDiv').style.display = 'none';
		var theForm = document.frmQuickUpdForm;
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one')
				theForm.elements[p].style.display = '';
		}
	}
	//document.getElementById('GenStatusDiv').style.display = 'none';
	
	//alert(comid.id + " --- " + comid.parentNode + " --- " + comid.name);
	/*for(property in comid)
    {
         // Show "property" and "type property"
         nodeName = "IMG"
         nodeValue = "null";
         nodeType = 1
         parentNode = "javascript:void(0)"
         childNoted = list
         firs
         localName = "IMG"
         tagName
         id = ""
         title = ""
         lang = ""
         dir = ""
         className = ""
         name = ""
         align = ""
         alt = ""
         src
          alert(property + " --- " + comid[property]);
     }*/
	return true;
}

function sedoUpdate()
{
	document.frmChange.submit();
	return true;
}

function showSiteList(targ,selObj){
		  
		  for (i=0;i<selObj.length;i++) 
			{ 
		      if (selObj[i].checked) 
		      { 
		             value = selObj[i].value; 
		      } 
			} 

	 eval(targ+".location='"+selObj.value+"'");
}

function sortList(targ,selObj,restore){
		  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		  if (restore) selObj.selectedIndex=0;
		}
function is_null(text) {
        var regex = /^\s*$/;
        if(regex.test(text)){
                return true;
        }
        return false;
}

