function showhide_show(layer_ref) {
	var state = 'block';
	//display:block
	//display:none
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].display = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.display = state;
	}
}
function showhide_hide(layer_ref) {
	var state = 'none';
	//display:block
	//display:none
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].display = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.display = state;
	}
}
function PRevenuevalcheck()
{
   var msg = "";
  if (document.pub_revenue.DisplayedURL.value == ""){
     document.pub_revenue.DisplayedURL.focus();
	 msg += "Enter Your URL \n";
  }


  if (document.pub_revenue.IndustryID.value == "")
     msg += "Select Industry \n";

	 if (document.pub_revenue.ch_in_1_end.checked == false && document.pub_revenue.ch_in_2_end.checked == false && document.pub_revenue.ch_in_3_end.checked == false )
     msg += "Choose Interest \n"


	if (document.pub_revenue.UniqueVisitors.value == "")
     msg += "Enter Average Number Of Unique Visitors Per Month \n";
	 
	 if (document.pub_revenue.ch_1_val.checked == false && document.pub_revenue.ch_2_val.checked == false && document.pub_revenue.ch_3_val.checked == false )
     msg += "Choose Type of Ad \n"
	 
	
	 
	
  if (document.pub_revenue.AvailableAdSlots.value == "")
     msg += "Available Ad Slots \n";
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
       document.pub_revenue.submit();
     
}
function Pvalcheck()
{
   var msg = "";
  if (document.loginpub.DisplayedURL.value == "")
     msg += "Enter DisplayedURL \n";
  if (document.loginpub.FirstName.value == "")
     msg += "Enter first name \n";
  if (document.loginpub.LastName.value == "")
     msg += "Enter second name \n"
  
  if (document.loginpub.Password.value == "")
     msg += "Enter password \n"
  if (document.loginpub.cpass.value == "")
     msg += "Enter password confirmation \n";
  if (document.loginpub.Password.value != document.loginpub.cpass.value)
     msg += "Retype password confirmation \n";

 if ((document.loginpub.IndustryID.value == "")||(document.loginpub.IndustryID.value == "0"))
     msg += "Enter Industry\n"
	 if (document.loginpub.PaypalEmail.value == "")
     msg += "Enter Paypal Email \n"
	 
  if (document.loginpub.UniqueVisitors.value == "")
     msg += "Enter Unique Visitors \n"	 	 
  if (document.loginpub.ReceivePayments.value == "")
     msg += "Enter Receive Payments\n"	 
  if (document.loginpub.ZytchLoginEmail.value == "")
     msg += "Enter Zytch Login Email\n"	 
  if (document.loginpub.ChequeAddress.value == "")
     msg += "Enter Cheque Address\n"	 
  if (document.loginpub.BankDetails.value == "")
     msg += "Enter Bank Details\n"
 	 
  
  if (document.loginpub.agree.checked == false )
     msg += "Please read the terms and conditions \n";
  
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
       document.loginpub.submit();
     
}

function Avalcheck()
{
   var msg = "";
   gotChecked = false;
   frmElements = document.forms['loginadv'].elements;
   for(i = 0; i < frmElements.length; i ++)
   	if(frmElements[i].name.substr(0, 3) == "cbx")
		if(frmElements[i].checked)
			gotChecked = true;
  if (!gotChecked)
     msg += "Check at least a slot to advertise on \n";
  if (document.loginadv.FirstName.value == "")
     msg += "Enter first name \n";
  if (document.loginadv.SecondName.value == "")
     msg += "Enter last name \n"
  if (document.loginadv.EmailAddress.value == "")
     msg += "Enter email adress \n";
  if (document.loginadv.Password.value == "")
     msg += "Enter password \n"
  if (document.loginadv.cpass.value == "")
     msg += "Enter password confirmation \n";
  if (document.loginadv.Password.value != document.loginadv.cpass.value)
     msg += "Retype password confirmation \n";
 if (document.loginadv.agree.checked == false )
   msg += "You must agree with the terms and conditions \n";

  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
	if(check_picture())
       document.loginadv.submit();
     
}

function check_picture() {
  var ext = document.loginadv.pic.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();

  if(ext != 'jpg' && ext != 'gif') {
    alert('You selected a .'+ext+
          ' file; please select a .jpg or .gif file instead!');
    return false; }
  else
    return true; }

function submit_search()
{
  var msg = "";
  if (document.search_form.txtSearch.value == "")
     msg += "Please enter keyword \n";
  if (msg != "") { alert(msg); return false; }
 else
       document.search_form.submit();
     
}
//check the PUBLISHER registration
function Calculationcheck()
{
  var msg = "";
  


    if (document.frm_calc.UniqueVisitors.value == "")
     msg += "Enter Average Number of Unique Visitors Per Month \n";

    if (document.frm_calc.AgeID.value == "")
     msg += "Choose Age \n";

    if (document.frm_calc.SexID.value == "")
     msg += "Choose Sex \n";

  if (document.frm_calc.Payment.value == 0)
     msg += "Choose and Fill Preferred payment method to receive payments\n";


  if (document.frm_calc.EmailAddress.value == "")
     msg += "Enter Your Personal Email Address\n";

  //if (document.frm_calc.ZytchLoginEmail.value == "")
  //   msg += "Enter Zytch.com Username\n";
  
  if (document.frm_calc.FirstName.value == "")
     msg += "Enter First Name \n";

  if (document.frm_calc.LastName.value == "")
     msg += "Enter Last Name \n";

   if (document.frm_calc.Password.value == "")
     msg += "Enter password \n"
  if (document.frm_calc.cpass.value == "")
     msg += "Enter password confirmation \n";
  if (document.frm_calc.Password.value != document.frm_calc.cpass.value)
     msg += "Retype password confirmation \n";
  
  if (document.frm_calc.agree.checked == false )
     msg += "Are you agree with terms and conditions? \n";
  
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
       document.frm_calc.submit();
}

//check the PUBLISHER registration
function EditPublishercheck()
{
  var msg = "";
  
    if (document.frm_calc.UniqueVisitors.value == "")
     msg += "Enter Average Number of Unique Visitors Per Month \n";

  if (document.frm_calc.Payment.value == 0)
     msg += "Choose and Fill Preferred payment method to receive payments\n";


  if (document.frm_calc.EmailAddress.value == "")
     msg += "Enter Your Personal Email Address\n";

  if (document.frm_calc.ZytchLoginEmail.value == "")
     msg += "Enter Zytch.com Username\n";
  
  if (document.frm_calc.FirstName.value == "")
     msg += "Enter First Name \n";

  if (document.frm_calc.LastName.value == "")
     msg += "Enter Last Name \n";

   if (document.frm_calc.Password.value == "")
     msg += "Enter password \n"
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
       document.frm_calc.submit();
}


function val_pub_check()
{
	//calculate the $$ for Publisher - INDEX PAGE
	var msg = "";
	if (document.frm_publisher.DisplayedURL.value == "" || document.frm_publisher.DisplayedURL.value == "Enter your website URL...")
	     msg += "Enter your website URL...\n";
	if (msg != "")
	{
		alert(msg);
		return false;
	}
	else
	{

	document.getElementById('overall').style.display = "block";

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }

	xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				//set the frm_calculate values
				document.frm_calculate.DisplayedURL.value = document.frm_publisher.DisplayedURL.value;
				document.frm_calculate.IndustryID.value = document.frm_publisher.IndustryID.value;
				document.frm_calculate.AdTypesValue.value = document.frm_publisher.AdTypesValue.value;
				document.frm_calculate.PagePositionID.value = document.frm_publisher.PagePositionID.value;
				document.frm_calculate.SlotID.value = document.frm_publisher.SlotID.value;
				document.frm_calculate.xGetPriceSlots.value = xmlHttp.responseText;
				document.getElementById('TotalPrice').innerHTML = xmlHttp.responseText;
				document.getElementById('overall').style.display = "none";
			}
		}
		xmlHttp.open("POST","calc_rating.php?rand="+Math.random(),true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		msg = "DisplayedURL=" + encodeURI(document.frm_publisher.DisplayedURL.value)
			+ "&IndustryID=" + encodeURI(document.frm_publisher.IndustryID.value)
			+ "&AdTypesValue=" + encodeURI(document.frm_publisher.AdTypesValue.value)
			+ "&PagePositionID=" + encodeURI(document.frm_publisher.PagePositionID.value)
			+ "&SlotID=" + encodeURI(document.frm_publisher.SlotID.value);
		xmlHttp.send(msg);
	//old style
//		document.frm_publisher.action="index.php";
//		document.frm_publisher.submit();
	}
}

//from the index page, Sign Up Today to Get Started
function go_to_insert(){
		 var msg = "";
  if (document.frm_calculate.DisplayedURL.value == "" || document.frm_calculate.DisplayedURL.value == "Enter your website URL...")
     msg += "Enter your website URL...\n";
	 
	 if (document.frm_calculate.xGetPriceSlots.value == "" || document.frm_calculate.xGetPriceSlots.value == 0 )
     msg += "Before press `Sign Up Today to Get Started` you should press `Calculate` button \n";
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
	document.frm_calculate.action="calculation.php";
	document.frm_calculate.submit();

}

//from the index page, Sign Up Today to Get Started
function go_to_insert_auth(){
		 var msg = "";
  if (document.frm_calculate.DisplayedURL.value == "" || document.frm_calculate.DisplayedURL.value == "Enter your website URL...")
     msg += "Enter your website URL...\n";
	 
	 if (document.frm_calculate.xGetPriceSlots.value == "" || document.frm_calculate.xGetPriceSlots.value == 0 )
     msg += "Before press `Sign Up Today to Get Started` you should press `Calculate` button \n";
  
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
	document.frm_calculate.action="addPublisherSite.php";
	document.frm_calculate.submit();

}


//from the index page, Sign Up Today to Get Started
function go_to_insertAdvertiser(){
		 var msg = "";

  //if (document.frm_advertiser.freetext.value == "" || document.frm_advertiser.freetext.value == "Free Keyword Search ...")
  //   msg += "Enter your Free Keyword Search...\n";
	 
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
	document.frm_advertiser.action="advertisersregistration.php";
	document.frm_advertiser.submit();

}


//check first page publisher search in case member is authenticated
function CheckFrmAuthenticated()
{
   var msg = "";
   gotChecked = false;
   frmElements = document.forms['loginadv'].elements;
   for(i = 0; i < frmElements.length; i ++)
   	if(frmElements[i].name.substr(0, 3) == "cbx")
		if(frmElements[i].checked)
			gotChecked = true;
  if (!gotChecked)
     msg += "Check at least a slot to advertise on \n";
  if (msg != "")
     {
	    alert(msg);
		return false;
	 }
 else
 {
 	document.loginadv.action="buyadspace_action.php";
	document.loginadv.submit();
 }
}
