// JavaScript Document
function hide (x) {
var k = document.getElementById(x);
k.style.display='none';
}

function show (x) {
var k = document.getElementById(x);
k.style.display='block';
}

/* function minimizediv (tar) {
k=document.getElementById(tar);
k.visibility='collapse';
}

function maximizediv (tar) {
k=document.getElementById(tar);
k.visibility='visible';
}
*/
function reducewindow (x,y) {
var k = document.getElementById(x);
k.visibility='hidden';
k.style.height=y + 'px';
k.innerHTML.visibility='hidden';
}

function maxwindow(x,y) {
var k = document.getElementById(x);
k.visibility='visible';
k.style.height=y + 'px';
k.innerHTML.visibility='visible';
}

function killdiv (divi) {
var advert=document.getElementById(divi);
document.body.removeChild(advert);
//advert.visibility='hidden'; 
}

function calldiv (divi) {
	var advert=document.getElementById(divi);
	document.body.appendChild(advert);
	}


function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function changecolor (divid,linkid,newcolor) {
k=document.getElementById(divid);
l=document.getElementById(linkid);
k.style.backgroundColor=newcolor;
l.style.color='#FFFFFF';
}

function resetcolor (divid,linkid,linkcolor) {
k=document.getElementById(divid);
l=document.getElementById(linkid);
k.style.backgroundColor='';
l.style.color=linkcolor;
}

function SetCookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
			
function limitText(limitField, limitCount, limitNum) {
lC=document.getElementById(limitCount);
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		lC.value = limitNum - limitField.value.length;
	}
}

function textLimit(field, maxlen) {
if (field.value.length > maxlen) {
field.value = field.value.substring(0, maxlen);
} }


function val_alpha_num(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
 		}
 return true;
}


function echeck(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 validIntlPhone (s) {
s=document.getElementById(s);
	if (s.value.length==0) return false; 
	else { 
		if (s.value.charAt(0)=='+') {s.value.replace('+','');}
		if (isNaN(s.value) | s.value.length<10) { return false; } else return true;
	} 
}

 function isNumberKey(evt)
  {
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
		return false;

	 return true;
  }