//------------------------  Trim functions ----------------------------------

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While

	return strTemp;
} //End Function

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++)
   {
      Char = sText.charAt(i);
      if(ValidChars.indexOf(Char) == -1)
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}

function CharAndSpace(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChar = "0123456789~`!@#$%^&*()_+|\\=-][{}:';?><,./'";
		var ValidChars = ValidChar+'"';
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) != -1)
			{
				return  false;
			}
		}
		return true;
	}
}

//Function to check the entered image is in .jpg,.gif,.jpeg,.png formot or not...
function checkimage(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];

                if((imageextention != 'jpg') & (imageextention != 'JPG') & (imageextention != 'gif') & (imageextention != 'jpeg') & (imageextention != 'png'))
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.gif\n.jpeg\n.jpg\n.png.");
			return false;
		}
	}
	return true;
}


//Function to check the enetred image is in .jpg.....
function checkimages(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];

                if((imageextention != 'jpg') & (imageextention != 'jpeg'))
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.jpg\n.jpeg");
			return false;
		}
	}
	return true;
}


//To vlaidate the document..
function checkfile(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];

                if((imageextention != 'doc') & (imageextention != 'docx') & (imageextention != 'txt') & (imageextention != 'pdf') & (imageextention != 'xls') & (imageextention != 'xlsx' ))
		{
			alert("-Please Upload Proper Document.\nAccept document format:\n.pdf\n.txt\n.doc\n.xls.");
			return false;
		}
	}
	return true;
}

//check email validation
function checkEmail(email)
{
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid contact E-Mail address! please re-enter.")
		return false;
	}else{
		alert("-Please enter your contact E-Mail address.")
		return false;
	}
}

//By clicking on Active, Inactive, Delete button...
function anyone(frm,message)
{
	with(frm)
	{
		var count = check.length;
		var i;
		for(i=0; i < count; i++)
		{
			if(check[i].checked)
			{
				var confirmation = confirm("-Do you want to do this operation.");
				if(confirmation) { return true; } else { return false; }
			}
		}
		alert("-Please select atleast one "+message+".");
		return false;
	}
}


//To select all colums in sponcer management...



var newwindow;
function popups(url)
{
	newwindow=window.open(url,'name','height=400,width=350,scrollbars=1');
	if (window.focus)
	{
		newwindow.focus();
	}
}

//function to submit to back page...
function backToMainPage(frm)
{
	with(frm)
	{
		document.location =	page_name.value;
	}
}


/*****************AJAX: To select the particular Client's Users: START******************/
//Coding to get the client's users...
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;
}

//To select the sub categories at the time of onchange...
function selectclientuser(str)
{
	//alert(str);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
 	{
  		alert ("-Your browser does not support AJAX!");
  		return;
   }
	var url="getclientsusers.php";
	url=url+"?id="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
//Check the execution is on which state...
function stateChanged()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("selectusers").innerHTML=xmlHttp.responseText;
	}
}
/*****************AJAX: To select the particular Client's Users: START******************/

function delclientuser(val1, val2){
var r=confirm("Do you wants to delete the record !");
if (r==true)
  {
  location.href="view_client_user.php?id="+val2+"&cuid="+val1+"&del=success";
  }
else
  {

  }
}

<!--
function setHeight(){
var y, myHeight;

// for all except Explorer
if (self.innerHeight) {
y = self.innerHeight;
myHeight =  y-207 + 'px';

// Explorer 6 Strict Mode
}
else if (document.documentElement
&& document.documentElement.clientHeight) {
y = document.documentElement.clientHeight;
myHeight = y-207 + 'px';

// other Explorers
} else if (document.body) {
y = document.body.clientHeight;
myHeight = y-207;
}
document.getElementById('setmyheight').style.height=myHeight;
}
//-->

<!--
function setHeight1(){
var y, myHeight;

// for all except Explorer
if (self.innerHeight) {
y = self.innerHeight;
myHeight =  y-242 + 'px';

// Explorer 6 Strict Mode
}
else if (document.documentElement
&& document.documentElement.clientHeight) {
y = document.documentElement.clientHeight;
myHeight = y-242 + 'px';

// other Explorers
} else if (document.body) {
y = document.body.clientHeight;
myHeight = y-242;
}
document.getElementById('setmyheight1').style.height=myHeight;
}
//-->

<!--
function setHeight2(){
var y, myHeight;

// for all except Explorer
if (self.innerHeight) {
y = self.innerHeight;
myHeight =  y-232 + 'px';

// Explorer 6 Strict Mode
}
else if (document.documentElement
&& document.documentElement.clientHeight) {
y = document.documentElement.clientHeight;
myHeight = y-232 + 'px';

// other Explorers
} else if (document.body) {
y = document.body.clientHeight;
myHeight = y-232;
}
document.getElementById('setmyheight2').style.height=myHeight;
}
//-->

function add_options(divname) {
	//alert(divname);
	strbooth = "";
	strbooth += "<div id='"+divname+incvalue+"'><table border='0' align='center' width='100%' >";
	strbooth +=' <tr>';
	strbooth +='<td align="left" nowrap width="5%">Image&nbsp;<strong>:</strong></td>';
	strbooth +='<td align="center" width="5%"></td>';
	strbooth +='<td align="left" colspan="2"><input type="file" name="image'+incvalue+'" id="image'+incvalue+'" size="38" value="" /></td>';
	strbooth +='</tr>'
	strbooth +=' <tr>';
	strbooth +='<td width="5%">&nbsp;</td>';
	strbooth +='<td width="5%">&nbsp;</td>';
	strbooth +='<td colspan="2"><div style="font:Verdana, Arial, Helvetica, sans-serif; color:#FF6600; ">(Please upload only jpg images)</div></td>';
	strbooth +='</tr>'
	strbooth +=' <tr>';
    strbooth +='<td valign="top">Comments&nbsp;<strong>:</strong></td>';
    strbooth +='<td valign="top">&nbsp;</td>';
    strbooth +='<td width="30%"><textarea name="comments'+incvalue+'" id="comments'+incvalue+'" rows="4" cols="35" class="txtarea"></textarea></td>';
	strbooth += '<td class="des_07" align="left" valign="top"><a href="#" onclick="javascript:return cancel_options(\''+divname+incvalue+'\');" class="link02">Cancel</a></td>';
    strbooth +='</tr>';
	strbooth += '</table></div>';
	document.getElementById(divname).innerHTML = document.getElementById(divname).innerHTML + strbooth;
	incvalue++;
	return false;
}
function cancel_options(id) {
	document.getElementById(id).innerHTML="";
	document.getElementById(id).style.display="none";
	return false;
}
function del_Image(delid) {
	document.getElementById('del_img').value=document.getElementById('del_img').value+","+delid;
	document.getElementById('img_'+delid).style.display='none';
}


function validateaddnewemploy(frm){
	with(frm)
	{
		if(clientid.value=='0')
		{
			alert('Please select a Client.');
			clientid.focus();
			return false;
		}
    }
	return true;
}


function validateevents(frm){
	with(frm){

			if(Trim(heading.value)==''){
			alert('-Please enter the heading.');
			heading.focus();
			return false;
		}
		if(Trim(Date.value)==''){
			alert('-Please select the date.');
			Date.focus();
			return false;
		}
		if(Trim(body.value)==''){
			alert('-Please select the eventdescription.');
			body.focus();
			return false;
		}

	}
	return true;
}
function validategallery(frm)
{
	with(frm)
	{
		if(gallery.value == '')
		{
			alert("-Please enter the Gallery Name.");
			gallery.focus();
			return false;
		}
	}
	return true;
}

function chk_subscribeMessage(dvid)

{

	frm=document.frmsubscribe;
		if(!checkEmail(frm.email.value))
		{
			return false;
		}

	else
	{
		var subval=frm.email.value;
		frm.email.value="";
		subscribeMessage(subval,dvid);
	}

}

function opendiv(val1,val2){
	
	if(val1) {
		document.getElementById('div_open').style.display='block';
		
	}
	else {
		document.getElementById('div_close').style.display='none';
	}
}


function company_headDetails(option) {
	document.getElementById('div_comclose').style.display="none";
	document.getElementById('div_comopen').style.display="none";
	if(option=="open") {
		document.getElementById('div_comopen').style.display="block";
	} else {
		document.getElementById('div_comclose').style.display="block";
	}
}
function validateregister(frm)
{
	//alert("gfgffgh");
	with(frm)
	{
		if(Trim(firstname.value)=='')
		{
				alert('-Please enter the firstname.');
				firstname.focus();
				return false;
		}
		if(Trim(lastname.value)=='')
		{
				alert('-Please enter the lastname.');
				lastname.focus();
				return false;
		}
		if(Trim(companyname.value)=='')
		{
				alert('-Please enter the  company name.');
				companyname.focus();
				return false;
		}
		if(Trim(company.value)=='')
		{
				alert('-Please enter the your position in the company.');
				company.focus();
				return false;
		}
		
		if(Trim(phone.value)=='')
		{
			alert('Please enter the phone number.');
			phone.focus();
			return false;
		}
		if(!IsNumeric(phone.value))
		{
			alert('phone number should be numeric.');
			phone.focus();
			return false;
		}
		if(phone.value.length <=9)
		{
			alert('phone number should be ten digits.');
			phone.focus();
			return false;
		}
		if (email.value == "")
	    {
		   alert("Please enter the e-mail address.");
		   email.focus();
		   return false;
	    }
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		
		if(country.value=='')
		{
			alert("please select the country");
			country .focus()
			return false;
		}
		if(security_code.value=='')
		{
			alert("please enter	 the securitycode");
			security_code .focus()
			return false;
		}
	
	}
	return true;
}
function validateadmincms(frm)
{
	
	with(frm)
	{
		
		if(Trim(title.value) == "")
		{
			alert("-Please enter the  title.");
			title.focus();
			return false;
		}
		if(Trim(desc.value) == "")
		{
			alert("-Please enter the  description.");
			desc.focus();
			return false;
		}
		if(FCKeditorAPI.GetInstance('contents').GetXHTML() == '')
		{
			alert("-Please enter the content.");
			contents.focus();
			return false;
		}
     
	 }
	return true;
}
function validatecontact(frm)
{
	with(frm)
	{
		if(Trim(fname.value)=='')
		{
				alert('-Please enter the firstname.');
				fname.focus();
				return false;
		}
		if(Trim(lname.value)=='')
		{
				alert('-Please enter the lastname.');
				lname.focus();
				return false;
		}
		if(Trim(company.value)=='')
		{
				alert('-Please enter the company.');
				company.focus();
				return false;
		}
		if(Trim(position.value)=='')
		{
				alert('-Please enter the position in the company.');
				position.focus();
				return false;
		}		
		if(Trim(Address.value)=='')
		{
				alert('-Please enter the address.');
				Address.focus();
				return false;
		}
		if(Trim(City.value)=='')
		{
				alert('-Please enter the city.');
				City.focus();
				return false;
		}
		if(Trim(State.value)=='')
		{
				alert('-Please enter the state.');
				State.focus();
				return false;
		}
	
		if(Trim(Zip.value)=='')
		{
			alert('Please enter the zipcode.');
			Zip.focus();
			return false;
		}
		if(!IsNumeric(Zip.value))
		{
			alert('zipcode should be numeric.');
			Zip.focus();
			return false;
		}
		if(Zip.value.length <=4)
		{
			alert('zipcode should be five digits.');
			Zip.focus();
			return false;
		}
		if (email.value == "")
	   {
		   alert("Please enter the e-mail address.");
		   email.focus();
		   return false;
	   }
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(State.value)=='')
		{
				alert('-Please enter the state.');
				State.focus();
				return false;
		}
		if(Trim(phone.value)=='')
		{
			alert('Please enter the telephone number.');
			phone.focus();
			return false;
		}
		if(!IsNumeric(phone.value))
		{
			alert('telephone number should be numeric.');
			phone.focus();
			return false;
		}
		if(phone.value.length <=9)
		{
			alert('telephone number should be ten digits.');
			phone.focus();
			return false;
		}
		if(Trim(Comments.value)=='')
		{
				alert('-Please enter the comments.');
				Comments.focus();
				return false;
		}
	
	}
	return true;
}

function validatecareer(frm){
	with(frm) {
		if(Trim(fname.value)==''){
			alert('Please enter the first name.');
			fname.focus();
			return false;
		}
		if(Trim(lname.value)==''){
			alert('Please enter the last name.');
			lname.focus();
			return false;
		}
		if(Trim(email.value)==''){
			alert('Please enter the email id.');
			email.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(skill.value)==''){
			alert('Please enter the ore skills.');
			skill.focus();
			return false;
		}
		if(resume.value != '')
		{
			if(!checkfile('frmcareers','resume'))
			{
			return false;
			}
		}
	}
	return true;
}
function validateclient(frm){
	with(frm) {
		if(Trim(client_name.value)==''){
			alert('Please enter the client name.');
			client_name.focus();
			return false;
		}
	}
	return true;
}
function validatelink(frm){
	with(frm) {
		if(Trim(link_name.value)==''){
			alert('Please enter the link name.');
			link_name.focus();
			return false;
		}
		if(Trim(url.value)==''){
			alert('Please enter the url.');
			url.focus();
			return false;
		}
	}
	return true;
}
function validateeventcal(frm)
{
	with(frm)
	{
		if(Trim(title.value)=='')
		{
				alert('-Please enter the title.');
				title.focus();
				return false;
		}
		if(Trim(desc.value)=='')
		{
				alert('-Please enter the description.');
				desc.focus();
				return false;
		}
		if(Trim(Start.value)=='')
		{
				alert('-Please select the start date.');
				Start.focus();
				return false;
		}
		/*if(Trim(starttimehr.value)=='')
		{
				alert('-Please select the starttime hours.');
				starttimehr.focus();
				return false;
		}
		if(Trim(starttimemin.value)=='')
		{
				alert('-Please select the starttime minutes.');
				starttimemin.focus();
				return false;
		}*/
		if(Trim(End.value)=='')
		{
				alert('-Please select the End date.');
				End.focus();
				return false;
		}
		/*if(Trim(endtimehr.value)=='')
		{
				alert('-Please select the endtime hours.');
				endtimehr.focus();
				return false;
		}
		if(Trim(endtimemin.value)=='')
		{
				alert('-Please select the endtime minutes.');
				endtimemin.focus();
				return false;
		}*/
		if(Trim(location.value)=='')
		{
				alert('-Please enter the location.');
				location.focus();
				return false;
		}
		if(Trim(website.value)=='')
		{
				alert('-Please enter the website.');
				website.focus();
				return false;
		}
		/*if(Trim(eve_img.value)=='')
		{
				alert('-Please enter the logo.');
				eve_img.focus();
				return false;
		}
		if(eve_img.value != '')
		{
			if(!checkimage('eventcal','eve_img'))
			{
			return false;
			}
		}*/
		
	}
	return true;
}
/*function validateviewclientselect(frm)
{
	alert("ddscdsds");
	with(frm)
	{
		if(Trim(zip_files.value)=='')
		{
				alert('-Please select the title.');
				zip_files.focus();
				return false;
		}
		if(Trim(zip_comments.value)=='')
		{
				alert('-Please enter the comments.');
				zip_comments.focus();
				return false;
		}
	}
	return true;
}*/



