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='Advance 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='Base Search';
			}
		}
	}
}

function validate_contact_form(){
   if(document.domain_contact_form.name.value=='') {
      alert("Please enter name");
	  return false;
   }
   if(document.domain_contact_form.email.value=='') {
      alert("Please enter email");
	  return false;
   }
   if(document.domain_contact_form.phone.value=='') {
      alert("Please enter phone");
	  return false;
   }
   if(document.domain_contact_form.address.value=='') {
      alert("Please enter address");
	  return false;
   }
   if(document.domain_contact_form.city.value=='') {
      alert("Please enter city");
	  return false;
   }
   if(document.domain_contact_form.state.value=='') {
      alert("Please enter state");
	  return false;
   }
   if(document.domain_contact_form.postcode.value=='') {
      alert("Please enter postcode");
	  return false;
   }
   if(document.domain_contact_form.country.value=='') {
      alert("Please select a 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;
		}