function terms(url)
{
	window.open(url+'gjtos.php?popup=1','houndtos', 'height=600,width=500,toolbar=no,scrollbars=yes,top=50,left=100,resizable=no');
	return false;
}
function newwindow(url)
{
	window.open(url,'NewWindow','height=500,width=800,scrollbars=yes,toolbar=yes,menubar=yes,top=50,left=100,resizable=yes');
}
function cartoon()
{
	window.open('http://'+window.location.hostname+'/omarchives.html','Cartoon','height=345,width=258,scrollbars=no,toolbar=no,menubar=no,top=50,left=100,resizable=no');
}
function summers()
{
	window.open('lcsummerassociatepop.php','Summer','height=500,width=453,scrollbars=yes,toolbar=no,menubar=no,top=50,left=100,resizable=no');
}
function whatsthis2(page)
{
	OpenWin = this.open(page, "PopupWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=355,height=520,top=10,left=100");
}
function whatsthis1(page)
{
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=355,height=400,top=80,left=100");
}
function exclusive()
{
	OpenWin = this.open('lcexclusivepopup.php', "lcexclusive", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=246,height=152,top=100,left=100");
}
function givename()
{
	window.name="lcwa"
}
function popuptips()
{
	window.open('lcusagetipspopup.php','usagetips','height=268,width=264,scrollbars=yes,toolbar=no,menubar=no,top=50,left=100,resizable=no');
}

function popuppostnewjob(url)
{
	window.open(url,'NewWindow','height=200,width=350,scrollbars=yes,toolbar=no,menubar=no,top=50,left=100,resizable=no');
}


function mailtocolleague(title,url)
{
	var strurl = "http://"+window.location.hostname+"/lcmailtocolleague.php?a=a";

	if(typeof(title)!="undefined")
		strurl = strurl + "&title="+escape(title);
  	if(typeof(url)!="undefined")
		strurl = strurl + "&url=" + escape(url);
	window.open(strurl,'mailtocollegue','height=383,width=355,scrollbars=yes,toolbar=no,menubar=no,top=80,left=100');
}
function mailnewswiretofriend(url)
{

	var strurl = "http://"+window.location.hostname+"/lcmailtocolleague.php?a=a";
	alert(strurl);
  	if(typeof(url)!="undefined")
		strurl = strurl + "&url=" + escape(url);
	window.open(strurl,'mailtocollegue','height=383,width=355,scrollbars=yes,toolbar=no,menubar=no,top=80,left=100');
}

function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

var dtCh= "/";
var minYear=01;
var maxYear=99;
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checklength(obj,len)
{
	var temp = obj.value;
	if(temp.length < len)
		return false;
	return true;
}

//Link Rollover starts here
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//link rollover ends here

//pre load images scrip starts here
var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
//Enter path of images to be preloaded inside parenthesis. Extend list as desired.
//preloadimages("images/abouttma.gif","images/whatwedoa.gif","images/provenrslta.gif","images/pricinga.gif")
//preload images scrip ends here
function lostarticlestring()
{
	document.articleform.clsarticle_keywords.value="";
}
function articlesearch()
{
	if(ValidatorTrim(document.articleform.clsarticle_keywords.value)=="")
	{
		alert("Keywords are required field");
	}
	else if(ValidatorTrim(document.articleform.clsarticle_keywords.value)=="Search Article")
	{
		alert("Keywords are required field");
	}
	else{
		document.articleform.submit();
	}
}
function lostexcarticlestring()
{
	document.articleform.clsarticle_exckeywords.value="";
}
function articleexcsearch()
{
	if(ValidatorTrim(document.articleform.clsarticle_exckeywords.value)=="")
	{
		alert("Keywords are required field");
	}
	else if(ValidatorTrim(document.articleform.clsarticle_exckeywords.value)=="Search Exclusive Articles")
	{
		alert("Keywords are required field");
	}
	else
	{
		document.articleform.action="lcexclusivearticlearchive.php";
		document.articleform.submit();
	}
}

function checkEmail(emailid)
{
	var error = "";
	if (emailid == '')
	{
		error	=	"You did not enter an email-address.\n";
	}

	//var invalidChars = '\/\'\\ ";:?!()[]\{\}^|#~`+*$%&'; //Changes By Himanshu Sharma on Tue Jun 03 12:27:34 IST 2008
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|#~`+*$%&,';

	for (i=0; i<invalidChars.length; i++)
	{
		if (emailid.indexOf(invalidChars.charAt(i),0) > -1)
		{
			error	=	"Please enter a valid email address.\n";
		}
	}

	for (i=0; i<emailid.length; i++)
	{
		if (emailid.charCodeAt(i)>127)
		{
			error	=	"Please enter a valid email address.\n";
		}
	}

	var atPos = emailid.indexOf('@',0);
	if (atPos == -1 || atPos == 0 || emailid.indexOf('@', atPos + 1) > - 1 || emailid.indexOf('.', atPos) == -1 || emailid.indexOf('@.',0) != -1 || emailid.indexOf('.@',0) != -1 || emailid.indexOf('..',0) != -1)
	{
		error	=	"Please enter a valid email address.\n";
	}

	var suffix = emailid.substring(emailid.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'COM' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum' && suffix != 'jobs')
	{
		error	=	"Please enter a valid email address.\n";
	}
	return error;
}

function addbookmark()
{
	bookmarkurl="http://www.lawcrossing.com/";
	bookmarktitle="LawCrossing";
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
}

//Made this function to work with
//left hand side quick links as add
//logos of other sites with link to that
//side. Have to open that site in new window
// with smallar size. Made by sachin on 2006-01-07
function leftsidemenu_openadvurl(url)
{
   var openurl="";
   if(url=="lsl"){ openurl = "http://www.lawschoolloans.com"; }
   else if(url=="ar"){ openurl="http://www.attorneyresume.com"; }
   else if(url=="la"){ openurl="http://www.legalauthority.com"; }
   else if(url=="bcg"){ openurl="http://www.bcgsearch.com"; }
   else if(url=="gj"){ openurl="http://www.goodjob.com/"; }
   else if(url=="judged"){ openurl="http://www.judged.com/"; }
   else if(url=="lc_postjob"){ openurl="http://www.lawcrossing.com/lctellusaboutjob.php"; }
   else if(url=="lfs_postjob"){ openurl="http://www.lawfirmstaff.com/erc/index.html"; }
   else if(url=="gj_postjob"){ openurl="http://www.gjonsulting.com/employer_resources.html"; }
   else if(url=="bcg_postjob"){ openurl="http://www.bcgsearch.com/"; }

   window.open(openurl,"","height=400,width=400,left=400,top=40,menubar=yes,location=yes,toolbar=yes,resizable=yes,scrollbars=yes,status=yes");
}

// from arg 28/08/2006 - added by mayur
function Set_Cookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	alert(value);
	/*
	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 Get_Cookie( name ) {

var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function MoveOption(objSourceElement, objTargetElement,flag)
{
	var aryTempSourceOptions = new Array();
	var x = 0;
 	//looping through source element to find selected options
	for (var i = 0; i < objSourceElement.length; i++) {
		if (objSourceElement.options[i].selected)
		{
			//if(flag != "D")
			//{
				var bln=true;
				for (var j = 0; j < objTargetElement.length; j++)
				{
					 if(objTargetElement.options[j].value == objSourceElement.options[i].value)
					 {
					 	bln=false;
					 }
				}
				if(bln)
				{
					//need to move this option to target element
					var intTargetLen = objTargetElement.length++;
					objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
					objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
				}
			//}
			//objSourceElement.options[i].selected=false;
	 	}

		else {
			//if(flag=="D")
			//{
				//storing options that stay to recreate select element
				var objTempValues = new Object();
				objTempValues.text = objSourceElement.options[i].text;
				objTempValues.value = objSourceElement.options[i].value;
				aryTempSourceOptions[x] = objTempValues;
				x++;
			//}
		}
 	}

	//if(flag=="D")
	//{
		//resetting length of source
		objSourceElement.length = aryTempSourceOptions.length;
		//looping through temp array to recreate source select element
		for (var i = 0; i < aryTempSourceOptions.length; i++)
		 {
			objSourceElement.options[i].text = aryTempSourceOptions[i].text;
			objSourceElement.options[i].value = aryTempSourceOptions[i].value;
			objSourceElement.options[i].selected = false;
		}
	//}
	var listobj;
	if(flag=="D")
	{
		listobj=objSourceElement
	}
	else
		listobj=objTargetElement

	var idstring,textstring;
	idstring="";
	textstring="";
	for (var j = 0; j < listobj.length; j++)
	{
		if(listobj.options[j].value != -1)
		{
			if(j!=listobj.length-1)
			{
				idstring=idstring+listobj.options[j].value+",";
				textstring=textstring+listobj.options[j].text+",<br>";
			}
			else
			{
				idstring=idstring+listobj.options[j].value;
				textstring=textstring+listobj.options[j].text;
			}
		}
	}
	Set_Cookie("IdString", idstring);
	Set_Cookie("TextString", textstring);
}

function checkEmailX(strng,fieldcaption)
{
	var error = "";
	if (strng == "")
		{
		error = "You did not enter an "+fieldcaption+".\n";
		}
	var emailFilter=/^.+@.+\..{2,4}$/;
	if (!(emailFilter.test(strng)))
		{
		error = "Please enter a valid "+fieldcaption+".\n";
		}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	if(strng.match(illegalChars))
		{
		error = "The "+fieldcaption+" contains illegal characters.\n";
		}
	return error;
}

//Link Rollover starts here
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//link rollover ends here

//pre load images scrip starts here
var myimages=new Array()
function preloadimages()
{
	for (i=0;i<preloadimages.arguments.length;i++)
	{
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}
function alwaysontop()
{
	window.focus();
}
//FOR FEDERAL EXIT
function show_too_busy()
{
	return overlib(loan,
	 STICKY, CAPTION,' ', CAPTIONPADDING,4, TEXTPADDING,8,
	 CGCLASS,'olcg', FGCLASS,'olfg', CAPTIONFONTCLASS,'olcap', TEXTFONTCLASS,'oltxt',
	 CLOSETEXT,myClose, CLOSECLICK, MIDX,0, MIDY,0, WRAP, BASE,3, SCROLL,
	 DRAGGABLE, SHADOW, SHADOWX,-1, SHADOWY,-1,
	 STATUS,'STICKY popup with link and secondary popup and FILTER for IE v5.5+',
	 FILTER);
}
function checkspecialchar(alphane)
{
	var str = alphane;
	for(var j=0; j<str.length; j++)
	{
		var alphaa = str.charAt(j);
		var chrcode = alphaa.charCodeAt(0);
		if((chrcode > 47 && chrcode<59) || (chrcode > 64 && chrcode<91) || (chrcode > 96 && chrcode<123) || chrcode==95)
		{
		}
		else
		{
			return false;
		}
	}
	return true;
}
function checkspecialcharexceptspace(alphane)
{
	var str = alphane;
	for(var j=0; j<str.length; j++)
	{
		var alphaa = str.charAt(j);
		var chrcode = alphaa.charCodeAt(0);
		if((chrcode > 47 && chrcode<59) || (chrcode > 64 && chrcode<91) || (chrcode > 96 && chrcode<123) || chrcode==95 || chrcode == 32)
		{
		}
		else
		{
			return false;
		}
	}
	return true;
}
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}
function showcuttext(id)
{
	var objmultiplecombo=document.getElementById(id);
	var showfulltext;
	showfulltext = '';

	for (var j = 0; j < objmultiplecombo.length; j++)
	{
		if(objmultiplecombo.options[j].value != -1 && objmultiplecombo.options[j].selected)
		{
			if(objmultiplecombo.options[j].text.length>42)
			{
				showfulltext += objmultiplecombo.options[j].text + '<br>';
			}
		}
	}

	document.getElementById('showfulltext').innerHTML = showfulltext;
}

// Modification By :: Jitendra Gohi
// Date : 10th May, 2007

function hidediv(id)
{
	jobid = id;
	id = 'hideshow_'+ id;

	if (document.getElementById)
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'hidden';
		document.getElementById(id).style.position='absolute';

		document.getElementById('txtareanote_'+jobid).value = document.getElementById('txtareanote_hdn_'+jobid).value;
		document.getElementById('txtboxnotealert_'+jobid).value = document.getElementById('txtareanotealert_hdn_'+jobid).value;
	}
	else
	{
		if (document.layers)
		{ // Netscape 4
			document.combinedid.visibility = 'hidden';
			document.combinedid.position='absolute';
		}
		else
		{ // IE 4
			document.all.id.style.visibility = 'hidden';
			document.all.id.style.position = 'absolute';
		}
	}
}


function showdiv(id) {
	if (document.getElementById)
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById(id).style.display = 'block';
		document.getElementById(id).style.position='relative';
	}
	else
	{
		if (document.layers)
		{ // Netscape 4
			document.id.visibility = 'visible';
			document.getElementById(id).style.display = 'block';
			document.id.position='relative';
		}
		else
		{ // IE 4
			document.all.id.style.visibility = 'visible';
			document.getElementById(id).style.display = 'block';
			document.all.id.style.position = 'relative';
		}
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	alert(id);
	alert(millisec);
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

	//make image transparent
	changeOpac(0, imageid);

	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;

	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
/**
 * Function for set focus on any filed.
 *
 * @param string formname < name of the form >
 * @param string fieldname <name of the field >
 *
 * @author Pratik Shah
 * @since  2-11-2006.
 */
function setfocus(formname,fieldname)
{
	var doc = "document.";
	var obj = eval(doc+formname+"."+fieldname);
	
	if(obj.type!='hidden' && obj.style.display!="none" && !obj.disabled)
	{
		obj.focus();
		//alert(obj.focus());
	}
	//eval(doc+formname+"."+fieldname+".focus()");
}
/**
 * Function added for the purpose of add search boxes on each page other than index.
 */
function checkfieldsmall()
{
	document.formsearch.clsjobsearch_hdnaction.value="Search";
	document.formsearch.submit();
}

function Set_Cookie(name,value,expires,path,domain,secure)
{

	var today = new Date();
	today.setTime( today.getTime() );
	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 getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );

}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


//  For AJAX Component
function createRequestObject()
{
	 var request_o;
	 var browser = navigator.appName;
	 //alert(window.opera);
	 if(!window.opera && browser == "Microsoft Internet Explorer")
	 {
	 	 request_o = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 else
	 {
	 	 request_o = new XMLHttpRequest();
	 }
	 return request_o;
}

function isSelected_Form_CheckBoxArray(formname,objname)
{
	var chkflg,strmessageid,url,returl;
	strmessageid="";
	chkflg=false;
	for(j=0; j<document.forms.length;j++)
	{
		if(document.forms[j].name==formname)
		{
			for (i=0;i<document.forms[j].elements.length;i++)
			{
				if (document.forms[j].elements[i].name==objname)
				{
					if (document.forms[j].elements[i].checked)
					{
						chkflg=true;
						break;
					}
				}
			}
		}
	}
	return chkflg;
}
/** checkbox function start */
function ChkValidate(frm,chkname){
	var validflag = false;
	for (i=0;i<document.forms[frm].elements.length;i++)
	{
		if (document.forms[frm].elements[i].name == chkname && document.forms[frm].elements[i].checked)
		{
			validflag = true;
			break;
		}
	}
	return validflag;
}
function chk_uncheck(frm,chkname,chkallobj){
	if(chkallobj.checked == true){
		checkAll(frm,chkname);
	} else {
		uncheckAll(frm,chkname)
	}
	return true;
}
function checkAll(frm,chkname)
{
     var docF=document.forms[frm];
     for(var i=0;i<docF.elements.length;i++)
     {
          if(docF.elements[i].name==chkname && docF.elements[i].type=="checkbox")
               docF.elements[i].checked=true;
     }
	 return true;
}
function uncheckAll(frm,chkname)
{
     var docF=document.forms[frm];
     for(var i=0;i<docF.elements.length;i++)
     {
          if(docF.elements[i].name==chkname && docF.elements[i].type=="checkbox")
               docF.elements[i].checked=false;
     }
	 return true;
}
function checkState(frm,chkname,chkallname)
{
	var flg=true;
	var docF=document.forms[frm];
    for(var i=0;i<docF.elements.length;i++)
    {
       if(docF.elements[i].name==chkname && docF.elements[i].type=="checkbox")
		{
	  		if(docF.elements[i].checked==false)
			{
				flg=false;
				break;
			}
		 }
     }
     document.getElementById(chkallname).checked=flg;
     return true;
}
/** checkbox function end */

//Center Popup
function NewWindowopen(mypage, myname, w, h, scroll) 
{
    if(screen.width) var winl = (screen.width - w) / 2;
    else  var winl = '';
    if(screen.height) var wint = (screen.height - h) / 2;
    else  var wint = '';
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,'', winprops)
   //  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


// Added by Fulchand Verma
var http = createRequestObject();
function AddMarketingEmail(firstname, email, source)
{
	var str = checkEmail(email);
	if(str == "")
	{
		var url= "gjaddmarketingemails.php?firstname="+firstname+"&source="+source+"&email="+email;
		http.open('get',url);
		//http.onreadystatechange = handleMarketingEmailResponse;
		http.send(null);
	}
}

/*function handleMarketingEmailResponse()
{

	if(http.readyState == 4)
	{


	}
}*/

//function will check the validations for subscription form
var formsubscription_submitted = false;
function checksubscriptionfields(formname)
{	
	email = eval('document.'+formname+'.clsuser_email.value');
	var err = '';
	var strFocusField =	'';
	var validemail = '';
	
	if(ValidatorTrim(email)=="")
	{		
		err += "Email address is required field. \n";
		if(strFocusField=='')
			strFocusField	=	"clsuser_email";
	}
	else
	{	
		validemail = checkEmail(ValidatorTrim(email));
		
		if(validemail!="")
		{
			err += checkEmail(email);
			strFocusField	=	"clsuser_email";
		}		
	}

	if(err!="")
	{
		alert(err);
		setfocus(formname,strFocusField);
		return false;
	}
	
	if(formsubscription_submitted)
	{
		return false;
	}
	else
	{
		var formsubscription = document.getElementById(formname);
		formsubscription_submitted = true;
		formsubscription.clsuser_hdnaction.value = "SaveFirstStepUser";
		formsubscription.clsuser_hdnsubmited.value = "1";
		return true;
	}	
}

function in_array(needle, haystack, strict) 
{
    var found = false, key, strict = !!strict;
 
    for (key in haystack) 
    {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
	}

	return found;
}

//

function isValidDate(dateStr) 
{
	// Date validation function courtesty of 
	// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) 
	{
		alert(dateStr + " Date is not in a valid format.")
		return false;
	}
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) 
	{ // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) 
	{
		alert("Day must be between 1 and 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		alert("Month "+month+" doesn't have 31 days!")
		return false;
	}
	if (month == 2) 
	{ // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) 
		{
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
	   }
	}
	return true;
}

function isValidTime(timeStr) 
{
	// Time validation function courtesty of 
	// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
	
	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
	
	var matchArray = timeStr.match(timePat);
	if (matchArray == null) 
	{
		alert("Time is not in a valid format.");
		return false;
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) 
	{
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	/*if (hour <= 12 && ampm == null) 
	{
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) 
		{
			alert("You must specify AM or PM.");
			return false;
		}
	}*/
	if  (hour > 12 && ampm != null) 
	{
		alert("You can't specify AM or PM for military time.");
		return false;
	}
	if (minute < 0 || minute > 59) 
	{
		alert ("Minute must be between 0 and 59.");
		return false;
	}
	if (second != null && (second < 0 || second > 59)) 
	{
		alert ("Second must be between 0 and 59.");
		return false;
	}
	return true;
}
/**
*function to generate the SearchResultLinkSeo
*/
function generateSearchResultLinkSeo(action,formname,newwindow)
{
	var q='';
	var l='';
	var country='';
	
	//var c='';
	var arrSearch = new Array('q','l','c');
	var arraSearchAdv = new Array('js_as_and','js_as_phr','js_as_any','js_as_not','js_ct','js_as_ttl','js_loc','js_as_cmp','country');
	var extraPara='';
	var queryStr = '';
	var strCookies = Get_Cookie('gjpreferences');
	if(strCookies==null || strCookies=='')
	{
		strCookies = "AGE=:DIS=25:LIMIT=50";
	}
	arrPreferenceCookies = strCookies.split(':');
	for(i=0;i<formname.length;i++)
	{
		if(formname.elements[i].name!="")
		{
			if(in_array(formname.elements[i].name,arrSearch))
			{
				if(formname.elements[i].name=="q" && formname.elements[i].value!="")
				q = formname.elements[i].value;
				if(formname.elements[i].name=="l" && formname.elements[i].value!="")
				l = formname.elements[i].value;
				if(formname.elements[i].name=="c" && formname.elements[i].disabled==false)
				{
					c = formname.elements[i].value;
				}
			}
			else if (in_array(formname.elements[i].name,arraSearchAdv))
			{
				if(formname.elements[i].name=="js_as_and" && formname.elements[i].value!="")
				q = q + ' ' + formname.elements[i].value;
				if(formname.elements[i].name=="js_as_phr" && formname.elements[i].value!="")
				q = q + ' "' + formname.elements[i].value + '"';
				if(formname.elements[i].name=="js_as_any" && formname.elements[i].value!="")
				q = q + ' (' + formname.elements[i].value + ')';
				if(formname.elements[i].name=="js_as_not" && formname.elements[i].value!="")
				{
					var strNotWords = formname.elements[i].value;
					//strNotWords = strNotWords.utf8_str_replace(","," ");
					strNotWords = strNotWords.replace('/((\".+?\")|(\'.+?\'))/','');

					arrNot = strNotWords.split(" ");
					if(arrNot.length>0)
					{
						for(j=0;j<arrNot.length;j++)
						{
							arr = new Array("\"","'",",");
							if(!in_array(arrNot[j],arr))
							{
								q = q + ' -' + arrNot[j];
							}
						}
					}
				}
				if(formname.elements[i].name=="js_ct" && formname.elements[i].value!="")
				{
					arrTitle = formname.elements[i].value.split(" ");
					if(arrTitle.length>1)
					q = q + ' category:(' + formname.elements[i].value + ')' ;
					else
					q = q + ' category:' + formname.elements[i].value;
				}
				if(formname.elements[i].name=="js_as_ttl" && formname.elements[i].value!="")
				{
					arrTitle = formname.elements[i].value.split(" ");
					if(arrTitle.length>1)
					q = q + ' title:(' + formname.elements[i].value + ')' ;
					else
					q = q + ' title:' + formname.elements[i].value  ;
				}
				if(formname.elements[i].name=="js_loc" && formname.elements[i].value!="")
				l = formname.elements[i].value;
				if(formname.elements[i].name=="js_as_cmp" && formname.elements[i].disabled==false)
				{
					c = formname.elements[i].value;
				}
				if(formname.elements[i].name=="country" && formname.elements[i].value!="")
				country = formname.elements[i].value;
			}
			else
			{
				if(formname.elements[i].name=='js_radius')
				js_radius = formname.elements[i].value;
				else if(formname.elements[i].name=='js_fromage')
				js_fromage = formname.elements[i].value;
				else
				extraPara = extraPara + "&" + formname.elements[i].name + "=" + urlencode(ValidatorTrim(formname.elements[i].value));
			}
		}
	}
	if(ValidatorTrim(l)=='')
			country = '';
	queryStr = queryStr + action+'?q='+urlencode(ValidatorTrim(q))+'&l='+urlencode(ValidatorTrim(l))+'&country='+urlencode(ValidatorTrim(country));
	
	if(typeof(js_radius) != "undefined")
	{
		queryStr = queryStr + '&js_radius='+urlencode(ValidatorTrim(js_radius));
	}
	else
	{
		js_radius = arrPreferenceCookies[1].replace('DIS=','');
		queryStr = queryStr + '&js_radius='+urlencode(ValidatorTrim(js_radius));
	}
	if(typeof(js_fromage) != "undefined")
	{
		queryStr = queryStr + '&js_fromage='+urlencode(ValidatorTrim(js_fromage));
	}
	else
	{
		js_fromage = arrPreferenceCookies[0].replace('AGE=','');
		queryStr = queryStr + '&js_fromage='+urlencode(ValidatorTrim(js_fromage));
	}
	if(typeof(c) != "undefined")
	{
		queryStr = queryStr + '&c='+urlencode(ValidatorTrim(c));
	}
	
	queryStr = queryStr +ValidatorTrim(extraPara);
	
	//document.location.href =  action+'?q='+ValidatorTrim(q)+'&l='+ValidatorTrim(l)+'&country='+ValidatorTrim(country)+'&c='+ValidatorTrim(c)+ValidatorTrim(extraPara);
	if(newwindow==false)
		document.location.href = queryStr;
	else
		window.open(queryStr);
}
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var histogram = {}, tmp_arr = [], unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}

function excludeFirmInSearching(flgExclude)
{
	if(flgExclude)
		document.cookie = "excludefirm=true";
	else
		document.cookie = "excludefirm=false";
	location.reload(true);
}