
function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}

function setctr(pst)
{
	for(var i=0;i<document.merchant.country.options.length;i++)
		if(document.merchant.country.options[i].value==pst)
			document.merchant.country.options[i].selected = true;
}

function setctrs(pst)
{
	for(var i=0;i<document.merchant.business_stcountry.options.length;i++)
		if(document.merchant.business_stcountry.options[i].value==pst)
			document.merchant.business_stcountry.options[i].selected = true;
}

function setctrind(pst)
{
	for(var i=0;i<document.merchant.business_industry.options.length;i++)
		if(document.merchant.business_industry.options[i].value==pst)
			document.merchant.business_industry.options[i].selected = true;
}

function setctrscl(pst)
{
	for(var i=0;i<document.merchant.business_scale.options.length;i++)
		if(document.merchant.business_scale.options[i].value==pst)
			document.merchant.business_scale.options[i].selected = true;
}


function setctrstate(pst)
{
	for(var i=0;i<document.merchant.state.options.length;i++)
		if(document.merchant.state.options[i].value==pst)
			document.merchant.state.options[i].selected = true;
}



//-----------------------------------------------------------------
function hideLoadingPage() 
{
	if (document.getElementById) 
	{  // DOM3 = IE5, NS6
	document.getElementById('ikoboloader').style.visibility = 'hidden';
	}
	else 
	{
		if (document.layers) 
		{  // Netscape 4
		document.ikoboloader.visibility = 'hidden';
		}
		else 
		{  // IE 4
		document.all.ikoboloader.style.visibility = 'hidden';
		}
	}
}

var d_load = false;
now_Date = new Date();
Month_now = now_Date.getMonth();
Year_now  = now_Date.getFullYear();
//----------------------------------------------------------------------

function loadDate()
	{
		if(d_load==false)
		{
	             getMonths();
		     getYears();
		     getDays();
        	     d_load=true;
	        }
	}

//--------------------------------------------------------------------
function getDays()
	{
		var day = 1;
		
		aday = new Option;
		aday.value = 0;
    	        aday.text = "Day";
		document.merchant.day.options[0]=aday;
		for(var y=day,i=1; y<day+31; ++y, ++i)
			{
        	aday = new Option;
	        aday.value = y;
    	        aday.text = y;
        	document.merchant.day.options[i]=aday;
        	    	}
		document.merchant.day.options[0].selected = true
		
	}
//--------------------------------------------------------------------
	
function getMonths()
	{
	
		var months = new Array("Month","January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
		
		for(var i=0; i<13; ++i)
		{
	   		newOpt = new Option;
		    	newOpt.value = i;
		    	newOpt.text = months[i];
			document.merchant.month.options[i] = newOpt;
		}
		
		document.merchant.month.options[0].selected = true
	}

//--------------------------------------------------------------------

function getYears()
	{
		var year = 1900;
		
		aYear = new Option;
		aYear.value = 0;
    	        aYear.text = "Year";
		document.merchant.year.options[0]=aYear;
		for(var y=year,i=1; y < year+86; ++y, ++i)
			{
        	aYear = new Option;
	        aYear.value = y;
    	        aYear.text = y;
        	document.merchant.year.options[i]=aYear;
        	    	}
		document.merchant.year.options[0].selected = true
		
	}

//--------------------------------------------------------------------

function setctr(pst)
{
	for(var i=0;i<document.merchant.country.options.length;i++)
		if(document.merchant.country.options[i].value==pst)
			document.merchant.country.options[i].selected = true;
			
		
		}




function submit_action(actioname)
{      
       // alert(actioname);
        
	document.tester.action.value=actioname;
	document.tester.submit();
	return false;	
}

function submit_edit(actioname)
{      
       // alert(actioname);
       // alert('Ready For Edit Here');
       
	return false;	
}

function submit_page(actioname)
{      
  // alert(actioname);        
	document.page_form.pg.value=actioname;
	document.page_form.submit();
	return false;	
}


function submit_haederaction(actioname)
{      
  //alert(actioname);
	if (actioname!=null && actioname=='go_account') {
		var email = document.hheader.cemail.value;
		var pass = document.hheader.cpass.value;
		if (email==null || email=='' || email.length>50) {
			alert('Incorrect Username/Password');
			return false;
		}
		if (pass==null || pass=='' || pass.length<6 || pass.length>10) {
			alert('Incorrect Username/Password');
			return false;
		}
		if (emailCheck(email)) {
			document.hheader.action.value=actioname;
			document.hheader.submit();
		}
	} else {
		document.hheader.action.value=actioname;
		document.hheader.submit();
	}
	return false;	
}

var xmlHttp


function ShowHomeWhy(str)
{ 
//alert(str);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="forms/ajaxpages/homewhy.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	url=url+"&ccID="
	xmlHttp.onreadystatechange=HomeTextChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function HomeTextChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("HomeHint").innerHTML=xmlHttp.responseText 
 } 
}

function ShowMyBillAccountRecharge(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/forms/ajaxpages/getmybillersc.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	url=url+"&ccID="
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function ShowMyBillAccount(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/forms/ajaxpages/getmybillers.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	url=url+"&ccID="
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function loadedEditData() {
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
	loadedEditData()
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function check_field(event, checkfild, action)
{
//event - podiya yaka vyklykaetcya presskey
//checkfild - obekt polya yake pereviryaetsya
//action - typ polya dlya perevirky
//abc - bukvy tilky
//digit - cyfry tilky
//phone - cyfry, probil, tere
var prevalues= checkfild.value;
switch(action)
{

	case 'abc'://test for abcd only
///////////////for Netscape////////////////////////////
	
if(navigator.appName=='Netscape')
{

	if(!event.ctrlKey)
	{if((event.charCode<47)||(event.charCode>58) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
//////////////for Microsoft Internet Explorer///////////
if(navigator.appName=='Microsoft Internet Explorer')
{
	if((event.keyCode<47) || (event.keyCode>58)){return -1;}
	else{return prevalues;}
}
///////////////////////////////////////////////
    break;
	case 'digit':
///////////////////////////////////////////////
if(navigator.appName=='Netscape')
{
	if(!event.ctrlKey)
	{if(((event.charCode>47) && (event.charCode<58)) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
///////////////////////////////////////////////
if(navigator.appName=='Microsoft Internet Explorer')
	{if((event.keyCode>47)&&(event.keyCode<58)){return -1;}
	else{return prevalues;}}	
///////////////////////////////////////////////
	break;		
	case 'phone':
///////////////////////////////////////////////
if(navigator.appName=='Netscape')
{
	if(!event.ctrlKey)
	{if(((event.charCode>47) && (event.charCode<58)) || (event.charCode==43) || (event.charCode==32) || (event.charCode==45) || (event.charCode==0)){return -1;}
	else{return prevalues;}}
	else{if((event.charCode==99)||(event.charCode==118) || (event.charCode==86)){return -1;}}
}
///////////////////////////////////////////////
if(navigator.appName=='Microsoft Internet Explorer')
	{if( ((event.keyCode>47) && (event.keyCode<58)) || (event.keyCode==43) || (event.keyCode==32) || (event.keyCode==45) || (event.keyCode==0)){return -1;}
	else{return prevalues;}}	
///////////////////////////////////////////////
	break;	
}	
}

function getposOffset(overlay, offsettype)
{
	var totaloffset = (offsettype == "left") ? overlay.offsetLeft : overlay.offsetTop;
	var parentEl = overlay.offsetParent;
	while (parentEl != null)
	{
		totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
		parentEl = parentEl.offsetParent;
	}
	return totaloffset;
}

function showBubble2(curobj, subobjstr, action, subj, opt_position)
{
	if (document.getElementById)
	{
		var subobj = document.getElementById(subobjstr);
		subobj.style.display = (subobj.style.display != "block") ? "block" : "none";
		var xpos = getposOffset(curobj, "left") + ((typeof opt_position != "undefined" && opt_position.indexOf("right") != -1) ? - (subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos = getposOffset(curobj, "top") + ((typeof opt_position != "undefined" && opt_position.indexOf("bottom")!=-1) ? curobj.offsetHeight : 0);
		xpos += 55;
		ypos -= 15 ;
		subobj.style.left = xpos + "px";
		subobj.style.top = ypos + "px";
		if (action==null || action=='')
		{
				document.getElementById("contentHead").innerHTML = subj;
				document.getElementById("content").innerHTML = "<br/>We are sorry, but description of this item is not available";
		}
		else
		{
				document.getElementById("contentHead").innerHTML = subj;
				document.getElementById("content").innerHTML = "<br/>"+action;
		}
		return false;
	}
	else
		return true;
}

function showBubble(curobj, subobjstr, action, opt_position)
{
	if (document.getElementById)
	{
		var subobj = document.getElementById(subobjstr);
		subobj.style.display = (subobj.style.display != "block") ? "block" : "none";
		var xpos = getposOffset(curobj, "left") + ((typeof opt_position != "undefined" && opt_position.indexOf("right") != -1) ? - (subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos = getposOffset(curobj, "top") + ((typeof opt_position != "undefined" && opt_position.indexOf("bottom")!=-1) ? curobj.offsetHeight : 0);
		xpos += 80;
		ypos -= 15 ;
		subobj.style.left = xpos + "px";
		subobj.style.top = ypos + "px";
		if (action==null || action=='')
		{
				document.getElementById("contentHead").innerHTML = "Description";
				document.getElementById("content").innerHTML = "<br/>We are sorry, but description of this item is not available";
		}
		else
		{
				document.getElementById("contentHead").innerHTML = "Description";
				document.getElementById("content").innerHTML = "<br/>"+action;
		}
		return false;
	}
	else
		return true;
}

function hideBubble(subobj)
{
	document.getElementById(subobj).style.display = "none";
}

/*
vi:ts=2
*/

