var submitted = false;
var error = false;
var error_message = "";

var url = document.location.href;
var xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

function  validateString( strValue ) {
 var objRegExp  =  /(^[a-zA-Z]+$)/; 
  return objRegExp.test(strValue);
}
function  validateNumeric( strValue ) {
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
 
  //check for numeric characters 
  return objRegExp.test(strValue);
}

function validateInteger( strValue ) {
  var objRegExp  = /(^-?\d\d*$)/;
 
  //check for integer characters
  return objRegExp.test(strValue);
}

function validateNotEmpty( strValue ) {
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }  
   return false;
}

function validateEmail( strValue) {
var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
  //check for valid email
  return objRegExp.test(strValue);
}

function rightTrim( strValue ) {
var objRegExp = /^([\w\W]*)(\b\s*)$/;
 
      if(objRegExp.test(strValue)) {
       //remove trailing a whitespace characters
       strValue = strValue.replace(objRegExp, '$1');
    }
  return strValue;
}

function leftTrim( strValue ) {
var objRegExp = /^(\s*)(\b[\w\W]*)$/;
 
      if(objRegExp.test(strValue)) {
       //remove leading a whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function trimAll( strValue ) {
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function validateCurrency( strValue)  {

  var objRegExp = /(^\$\d{1,3}(,\d{3})*\.\d{2}$)|(^\(\$\d{1,3}(,\d{3})*\.\d{2}\)$)/;

  return objRegExp.test( strValue );
}

function validateTime ( strValue ) {
  var objRegExp = /^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;

  return objRegExp.test( strValue );

}

function validateState (strValue ) {
var objRegExp = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i; 
  return objRegExp.test(strValue);
}

function validateSSN( strValue ) {
var objRegExp  = /^\d{3}\-\d{2}\-\d{4}$/;
 
  //check for valid SSN
  return objRegExp.test(strValue);

}



function validateUSPhone( strValue ) {
  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
 
  //check for valid us phone with or without space between 
  //area code
  return objRegExp.test(strValue); 
}


function validateUSZip( strValue ) {
var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
 
  //check for valid US Zipcode
  return objRegExp.test(strValue);
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function enter_key_for_register_page(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 daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
	} 
	return this
}

function isDate(dtStr)
{
	if(dtStr=='')
	{
		alert("Please enter date");
		return false;
	}
	else
	{
	var daysInMonth = DaysArray(12);	
	var pos1=dtStr.indexOf(dtCh);	
	var pos2=dtStr.indexOf(dtCh,pos1+1);	
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);	
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1)
	{
		alert("The date format should be : dd/mm/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || enter_key_for_register_page(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	return true
	}
}


function ValidateForm(datevalue){
	
	var dt=datevalue;
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }

function validateUrl(strValue) {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!v.test(strValue)) {
        return false;
    }
	else return true;
}

function replace(argvalue, x, y) {

  if ((x == y) || (parseInt(y.indexOf(x)) > -1)) {
    errmessage = "replace function error: \n";
    errmessage += "Second argument and third argument could be the same ";
    errmessage += "or third argument contains second argument.\n";
    errmessage += "This will create an infinite loop as it's replaced globally.";
    return false;
  }
    
  while (argvalue.indexOf(x) != -1) {
    var leading = argvalue.substring(0, argvalue.indexOf(x));
    var trailing = argvalue.substring(argvalue.indexOf(x) + x.length, 
	argvalue.length);
    argvalue = leading + y + trailing;
  }

  return argvalue;

}
function validateUSDate( strValue ) {
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 
  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var arrayDate = strValue.split(RegExp.$1); //split date into month, day, year
	var intDay = parseInt(arrayDate[1],10); 
	var intYear = parseInt(arrayDate[2],10);
    var intMonth = parseInt(arrayDate[0],10);
	
	//check for valid month
	if(intMonth > 12 || intMonth < 1) {
		return false;
	}
	
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
  
    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }
		
    //check for February
	var booLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
    if( ((booLeapYear && intDay <= 29) || (!booLeapYear && intDay <=28)) && intDay !=0)
      return true; //Feb. had valid number of days
  }
  return false; //any other values, bad date
}

function validateValue( strValue, strMatchPattern ) {
var objRegExp = new RegExp( strMatchPattern);
 
 //check if string matches pattern
 return objRegExp.test(strValue);
}


function removeCurrency( strValue ) {

  var objRegExp = /\(/;
  var strMinus = '';
 
  //check if negative
  if(objRegExp.test(strValue)){
    strMinus = '-';
  }
  
  objRegExp = /\)|\(|[,]/g;
  strValue = strValue.replace(objRegExp,'');
  if(strValue.indexOf('$') >= 0){
    strValue = strValue.substring(1, strValue.length);
  }
  return strMinus + strValue;
}

function addCurrency( strValue ) {
  var objRegExp = /-?[0-9]+\.[0-9]{2}$/;
   
    if( objRegExp.test(strValue)) {
      objRegExp.compile('^-');
      strValue = addCommas(strValue);
      if (objRegExp.test(strValue)){
        strValue = '($' + strValue.replace(objRegExp,'') + ')';
      }
      else {
        strValue = '$' + strValue;
      }
      return  strValue;
    }
    else
      return strValue;
}

function removeCommas( strValue ) {
  var objRegExp = /,/g; //search for commas globally
 
  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}

function addCommas( strValue ) {
  var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})'); 


    while(objRegExp.test(strValue)) {

       strValue = strValue.replace(objRegExp, '$1,$2');
    }
  return strValue;
}

function removeCharacters( strValue, strMatchPattern ) {
 var objRegExp =  new RegExp( strMatchPattern, 'gi' );
 
 //replace passed pattern matches with blanks
  return strValue.replace(objRegExp,'');
}
function fun_signin_validation()
{
	with(document.frm_login)
	{
		if(trimAll(document.getElementById('username').value)=="")
		{
			alert("Please enter your email address");
			document.getElementById('username').focus();
			document.getElementById('username').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('username').value))
		{
			alert("Please enter valid email address");
			document.getElementById('username').focus();
			return false;
		}
		else if(trimAll(document.getElementById('password').value)=="")
		{
			alert("Please enter password");
			document.getElementById('password').focus();
			document.getElementById('password').value="";
			return false;
		}
		else
		{
			document.getElementById('hdn_login').value="login";
			submit();
		}
	}
}
function fun_forget_validation()
{
	with(document.frm_forgot_password)
	{
		if(trimAll(document.getElementById('forget_email').value)=="")
		{
			alert("Please enter email address");
			document.getElementById('forget_email').focus();
			document.getElementById('forget_email').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('forget_email').value))
		{
			alert("Please enter valid email address");
			document.getElementById('forget_email').focus();
			return false;
		}
		else
		{
			document.getElementById('hdn_forgot').value="send_pass";
			submit();
		}
	}
}
function fun_changepass_validation()
{
	with(document.frm_change_password)
	{
		if(trimAll(document.getElementById('current_pass').value)=="")
		{
			alert("Please enter your current password");
			document.getElementById('current_pass').focus();
			document.getElementById('current_pass').value="";
			return false;
		}
		else if(trimAll(document.getElementById('new_pass').value)=="")
		{
			alert("Please enter the new password");
			document.getElementById('new_pass').focus();
			document.getElementById('new_pass').value="";
			return false;
		}
		else if(trimAll(document.getElementById('confirm_pass').value)=="")
		{
			alert("Please confirm the new password");
			document.getElementById('confirm_pass').focus();
			document.getElementById('confirm_pass').value="";
			return false;
		}
		else if(document.getElementById('new_pass').value != document.getElementById('confirm_pass').value)
		{
			alert("Confirm password doesn't match with new password");
			return false;
		}
		else
		{
			document.getElementById('hdn_change_pass').value="change_pass";
			submit();
		}
	}
}

//for validate the editor starts here

function validateTinyMCEEditor()
{
 tinyMCE.triggerSave(true,true); 
 var mytextarea = tinyMCE.getContent();
 if(mytextarea == "") 
	 {        
	  return true;   
	}  
}


function signin_newsvalidation()
{
	with(document.formsignin_newsletter)
	{
		if(trimAll(document.getElementById('fname').value)=="")
		{
			alert("Please enter your first name");
			document.getElementById('fname').focus();
			document.getElementById('fname').value="";
			return false;
		}
		else if(trimAll(document.getElementById('lname').value)=="")
		{
			alert("Please enter your last name");
			document.getElementById('lname').focus();
			document.getElementById('lname').value="";
			return false;
		}
		else if(trimAll(document.getElementById('company').value)=="")
		{
			alert("Please enter your company name");
			document.getElementById('company').focus();
			document.getElementById('company').value="";
			return false;
		}
		else if(trimAll(document.getElementById('email').value)=="")
		{
			alert("Please enter your email address");
			document.getElementById('email').focus();
			document.getElementById('email').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('email').value))
		{
			alert("Please enter valid email address");
			document.getElementById('email').focus();
			return false;
		}
		else
		{
			document.getElementById('Hdn_action').value="signinnews";
			submit();
		}
	}
}
function newssearchvalidation()
{
	with(document.frm_signin_newsletter)
	{
		if((trimAll(document.getElementById('keyword').value)=="") && (trimAll(document.getElementById('authorname').value)==""))
		{
			alert("Please enter your search keyword");			
			return false;
		}		
		else
		{
			document.getElementById('hdn_news_search').value="newssearch";
			submit();
		}
	}
}

function topsearch()
{
with(document.frmsearch)
	{
		if(trimAll(document.getElementById('search_terms').value)=="")
		{
			alert("Please enter your search keyword");	
			search_terms.value="";
			search_terms.focus();
			return false;
		}	
		else
		{	
		
			document.getElementById('hdn_search').value="topsearch";	
			submit();
			return true;   
		}
	}

}
function adv_search()
{
with(document.frmsearch)
	{
		if( (trimAll(document.getElementById('search_first').value)=="") && (trimAll(document.getElementById('search_second').value)=="") && (trimAll(document.getElementById('search_state').value)=="") && (trimAll(document.getElementById('search_country').value)=="") && (trimAll(document.getElementById('search_list').value)==""))
		{
			alert("Please enter your search keyword");	
			search_first.value="";
			search_first.focus();
			return false;
		}
		else
		{
			document.getElementById('hdn_search').value="advanced";
			hdn_listid.value='';
			submit();
			//setTimeout(document.getElementById('showloadimg').style.display="",4500)
			return true;   
		}
	}

}

function fnImportCsv(FrmName)
{	 
	location.href = "import.php";
}
function fun_checkall(parent_ctrlname,child_ctrlname,numofrows)
{
	for(chkbx=1;chkbx<=numofrows;chkbx++)
	{
		chkbx_id=child_ctrlname+chkbx;

		document.getElementById(chkbx_id).checked=true;
	}
}
function fnGetCsv(FrmName,ExportMode)
{		
	with(document.forms[FrmName])
	{	
		var resultcid			=new Array();
		if(ExportMode == "Selected")
		{
			t_len = total_chk.value;
			stat  = start.value;
			check_sel=false;
			for(i=1;i<=t_len;i++)
			{
				if(document.getElementById("chk"+i).checked==true)
				{
					check_sel=true;
					resultcid[i]=document.getElementById("chk"+i).value;		
				}
			}

			if(check_sel==false)
			{
				alert("Please select a contacts to export");
				return false;
			}
			else 
			{	
				document.frmsearch.hdnsel_contacts.value=resultcid;
				document.frmsearch.hdnMode.value="Csv";						
				document.frmsearch.submit();
				return true;
			}
		}
		else if(ExportMode == "list")
		{
			document.frmsearch.hdnMode.value="list";				
			document.frmsearch.submit();	
			return true;
		}
		else if(ExportMode == "addgroup")
		{
			t_len = total_chk.value;
			stat  = start.value;
			check_sel=false;
			for(i=1;i<=t_len;i++)
			{
				
				if(document.getElementById("chk"+i).checked==true)
				{
					check_sel=true;	
					resultcid[i]=document.getElementById("chk"+i).value;					
				}
			}
			if(document.getElementById('sel_group').value=='')
			{
				alert("Please select the group");
				return false;
			}
			if(check_sel==false)
			{
				alert("Please select a contacts to addgroup");
				return false;
			}			
			else 
			{	
				document.frmsearch.hid_sel_group.value=document.getElementById('sel_group').value;
				document.frmsearch.hdnsel_contacts.value=resultcid;
				document.frmsearch.hdnMode.value="addgroup";						
				document.frmsearch.submit();	
				return true;
			}
		}
		else
		{
			document.frmsearch.hdnMode.value="All";	
			document.frmsearch.submit();	
			return true;
		}
	}
}

function funimport()
{
	with(document.frm_ipmort)
	{
		file=trimAll(csvfile.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();
		if(trimAll(document.getElementById('csvfile').value)=="")
		{
			alert("Please browse your CSV to import the contacts");			
			return false;
		}	
		else if((!((ext=="csv")||(ext=="CSV"))) && (csvfile.value!='')) 
		{
		alert("You have selected a '."+ ext +"' file, please Select the file of type 'CSV'");				
		csvfile.focus();
		csvfile.value="";
		return false;
		}	
		else
		{
			document.getElementById('hdn_import').value="import";
			submit();
		}
	}
}

function pagetransfer(pagenumber,formname)
{ 
	with(document.forms[formname])
	{ 
		HdnPage.value=pagenumber;
		HiddenMode.value="paging";
		submit();
	}
}
function pagetransfersearch(pagenumber,formname)
{ 
	with(document.forms[formname])
	{ 
		HdnPage.value=pagenumber;
        document.frmsearch.action="";
		if(document.frmsearch.hdnMode)
		document.frmsearch.hdnMode.value="";
		HiddenMode.value="paging";
		submit();
	}
}

function pagetransfer2(pagenumber,formname)
{ 
	with(document.forms[formname])
	{
		HdnPage1.value=pagenumber;
		HiddenMode1.value="paging";
		submit();
	}
}
function pagetransfer1(pagenumber,formname)
{ 
	with(document.forms[formname])
	{ 
		HdnPage.value=pagenumber;
		HiddenMode.value="paging";
		if(hdnfiltersub.value=='yes')
		{
		   hdnfilter.value='yes';
		}
		submit();
	}
}
function sortbycolumn(formname,val,orderby)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"yes";
		 Hdnsortby.value=	val;
		 if(orderby=='ASC')
			 Hdnorder.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder.value	=	'ASC';
		 else
			  Hdnorder.value=	'DESC';
		 submit();
	}
}
function sortbycolumngroup(formname,val,orderby,group_id)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"yes";
		 Hdnsortby.value=	val;
		 if(orderby=='ASC')
			 Hdnorder.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder.value	=	'ASC';
		 else
			  Hdnorder.value=	'DESC';
		 action="tcl-group-contacts.php?sort="+val+"&order="+Hdnorder.value+"&g_id="+group_id;
		 submit();
	}
}
function sortbycolumnp(formname,val,orderby)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"yes";
		 Hdnsortby.value=	val;
		 if(orderby=='ASC')
			 Hdnorder.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder.value	=	'ASC';
		 else
			  Hdnorder.value=	'DESC';
		 action="tcl-project-detail.php";
		 submit();
		 target="";
	}
}
function sortbycolumn1(formname,val,orderby,pjt_id,action_url)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"yes1";
		 Hdnsortby.value=	val;
		 if(orderby=='ASC')
			 Hdnorder.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder.value	=	'ASC';
		 else
			  Hdnorder.value=	'DESC';
		 action=action_url+"?projectid="+pjt_id;
		 submit();
		 target="";
	}
}
function sortbycolumn2(formname,val,orderby)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"yes2";
		 Hdnsortby.value=	val;
		 if(orderby=='ASC')
			 Hdnorder.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder.value	=	'ASC';
		 else
			  Hdnorder.value=	'DESC';
		 action="";
		 submit();
		 target="";
	}
}
function sortbycolumn_per(formname,val,orderby)
{
	with(document.forms[formname])
	{
		 Hdnsort.value	=	"";
		 hdnpersonalsort.value="yes";
		 Hdnsortby1.value=	val;
		 if(orderby=='ASC')
			 Hdnorder1.value	=	'DESC';
		 if(orderby=='DESC')
			 Hdnorder1.value	=	'ASC';
		 else
			  Hdnorder1.value=	'DESC';
		 submit();
	}
}
function addlist(mode)
{
	with(document.frmlistmanage)
	{
		if(Packagename.value=="" && clistnames.value=="" && yearPackagename.value==""  && yearclistnames.value=="")		
		{
			alert("Please select package or list for add user's subscription");
			return false;
		}
		else
		{
		hid_mode.value=mode;
		submit();		
		}
	}
}
function delists(delid,mode)
{
	with(document.frmlistmanage)
	{
		var del_confirm = confirm("Do you really want to delete this contact(s)?");
		if(del_confirm==true)
		{
			hid_del_mode.value=mode;
			hid_del_id.value=delid;
			submit();
		}
	}
}


function fun_userdetail_validation()
{
	with(document.frm_edit_userdetails)
	{
		if(trimAll(document.getElementById('first_name').value)=="")
		{
			alert("Please enter the first name");
			document.getElementById('first_name').focus();
			document.getElementById('first_name').value="";
			return false;
		}
		else if(trimAll(document.getElementById('last_name').value)=="")
		{
			alert("Please enter the last name");
			document.getElementById('last_name').focus();
			document.getElementById('last_name').value="";
			return false;
		}		
		else if(trimAll(document.getElementById('email').value)=="")
		{
			alert("Please enter the email address");
			document.getElementById('email').focus();
			document.getElementById('email').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('email').value))
		{
			alert("Please enter valid email address");
			document.getElementById('email').focus();
			return false;
		}
		else if(trimAll(document.getElementById('telephone').value)=="")
		{
			alert("Please enter the telephone number");
			document.getElementById('telephone').focus();
			document.getElementById('telephone').value="";
			return false;
		}
		else if(trimAll(document.getElementById('contact_detail_views_per_day').value)=="")
		{
			alert("Please enter the number of contact detail views per day");
			document.getElementById('contact_detail_views_per_day').focus();
			document.getElementById('contact_detail_views_per_day').value="";
			return false;
		}
		else if(trimAll(document.getElementById('simultaneous_logins').value)=="")
		{
			alert("Please enter the number of simultaneous logins");
			document.getElementById('simultaneous_logins').focus();
			document.getElementById('simultaneous_logins').value="";
			return false;
		}
		else if(trimAll(document.getElementById('expiration_month').value)=="")
		{
			alert("Please enter the expiration month");
			document.getElementById('expiration_month').focus();
			document.getElementById('expiration_month').value="";
			return false;
		}
		else if(trimAll(document.getElementById('expiration_day').value)=="")
		{
			alert("Please enter the expiration day");
			document.getElementById('expiration_day').focus();
			document.getElementById('expiration_day').value="";
			return false;
		}
		else if(trimAll(document.getElementById('expiration_year').value)=="")
		{
			alert("Please enter the expiration year");
			document.getElementById('expiration_year').focus();
			document.getElementById('expiration_year').value="";
			return false;
		}
		else
		{
			document.getElementById('hdn_edit_user').value="edituser";
			submit();
		}
	}
}
function fun_billingdetails_validation()
{
	
	with(document.frm_edit_billingdetails)
	{
		if(trimAll(document.getElementById('name').value)=="")
		{
			alert("Please enter the name of card");
			document.getElementById('name').focus();
			document.getElementById('name').value="";
			return false;
		}
		else if(trimAll(document.getElementById('street_1').value)=="")
		{
			alert("Please enter the street address");
			document.getElementById('street_1').focus();
			document.getElementById('street_1').value="";
			return false;
		}		
		else if(trimAll(document.getElementById('city').value)=="")
		{
			alert("Please enter the city");
			document.getElementById('city').focus();
			document.getElementById('city').value="";
			return false;
		}		
		else if(trimAll(document.getElementById('state').value)=="")
		{
			alert("Please enter the state");
			document.getElementById('state').focus();
			document.getElementById('state').value="";
			return false;
		}
		else if(trimAll(document.getElementById('postcode').value)=="")
		{
			alert("Please enter the post code");
			document.getElementById('postcode').focus();
			document.getElementById('postcode').value="";
			return false;
		}
		else if(trimAll(document.getElementById('country_id').value)=="")
		{
			alert("Please select the country");
			document.getElementById('country_id').focus();
			document.getElementById('country_id').value="";
			return false;
		}
		else if(trimAll(document.getElementById('cc_num_trunc').value)=="")
		{
			alert("Please enter the credit card number");
			document.getElementById('cc_num_trunc').focus();
			document.getElementById('cc_num_trunc').value="";
			return false;
		}
		else if(!validateNumeric(document.getElementById('cc_num_trunc').value))
		{
			alert("Please enter the numeric value for credit card number");
			document.getElementById('cc_num_trunc').focus();
			document.getElementById('cc_num_trunc').value="";
			return false;
		}
		else if(trimAll(document.getElementById('expiration_month').value)=="")
		{
			alert("Please enter the expiration month");
			document.getElementById('expiration_month').focus();
			document.getElementById('expiration_month').value="";
			return false;
		}
		else if(trimAll(document.getElementById('expiration_year').value)=="")
		{
			alert("Please enter the expiration year");
			document.getElementById('expiration_year').focus();
			document.getElementById('expiration_year').value="";
			return false;
		}
		else if(trimAll(document.getElementById('cvv').value)=="")
		{
			alert("Please enter the cvv");
			document.getElementById('cvv').focus();
			document.getElementById('cvv').value="";
			return false;
		}
		else if(!validateNumeric(document.getElementById('cvv').value))
		{
			alert("Please enter the numeric value for cvv");
			document.getElementById('cvv').focus();
			document.getElementById('cvv').value="";
			return false;
		}
		else
		{
			document.getElementById('hdn_edit_bill').value="editbill";
			submit();
		}
	}
}


function removepair_option(mode,num,formname,price)
{
	with(document.forms[formname])
	{	
		
		var newprice		= parseInt(price);
		var curprice		= parseInt(document.getElementById("dynamic_price"+num).innerHTML);
		var oldtotprice		= parseInt(document.getElementById("total_list_price").innerHTML);
		if(mode=='month')
		{			
			document.getElementById("year_"+num).checked=false;
			document.getElementById("year_"+num).disabled=false;	
			document.getElementById("month_"+num).disabled=true;
				
		}
		else if(mode=='year')
		{
			
			document.getElementById("month_"+num).checked=false;
			document.getElementById("month_"+num).disabled=false;	
			document.getElementById("year_"+num).disabled=true;
					
		}		
		document.getElementById("dynamic_price"+num).innerHTML=newprice;		
		var newtotprice	= (oldtotprice - curprice) +newprice;
		document.getElementById("total_list_price").innerHTML = newtotprice;
		
	}
}

function removepair_option_all(mode,num,formname,price)
{
	with(document.forms[formname])
	{		
		if(mode=='month')
		{
			document.getElementById("year_"+num).checked=false;	
		}
		else if(mode=='year')
		{
			document.getElementById("month_"+num).checked=false;
		}		
		document.getElementById("all_lists").checked=false;
	}
}
function removeall_option()
{
	for(num=0;num<12;num++)
	{
	document.getElementById("month_"+num).checked=false;
	document.getElementById("year_"+num).checked=false;
	}
}

	function  fun_click_checkbox()
	{
		with(document.fullselection)
		{	
			t_len = total_chk.value;
			check_select=false;
			for(i=1;i<=t_len-1;i++)
			{
				if(document.getElementById("month_"+i).checked==true)
				{
					check_select=true;
					break;
				}
			}					
			for(i=1;i<=t_len-1;i++)
			{
				if(document.getElementById("year_"+i).checked==true)
				{
					check_select=true;
					break;
				}
			}
			/*if(document.getElementById("all_lists").checked==true)
			{
				check_select=true;		
				action='join-subscribe.php';
			}*/

			if(check_select==false)
			{
				alert("Please select a list to subscribe");
				return false;
			}
			else
			{
				fulllist.value="lists_alacarte";
				submit();		
				return true;
			}
		}
	}



function removepair_chekoutoption(mode,num)
{
	with(document.ordersummary)
	{		
		if(mode=='month')
			document.getElementById("year_"+num).checked=false;
		else if(mode=='year')
			document.getElementById("month_"+num).checked=false;
		
		
	}
}

function  fun_checkout_summary()
{
with(document.ordersummary)
	{		
	hid_order_summary.value="order";
	submit();		
	return true;		
	}

}
function fun_remove_order(order_value,listtype,FormName)
{
	
	with(document.forms[FormName])
	{		
	hid_order_summary.value="remove";
	selected_order.value   = order_value;
	order_type.value   = listtype;
	submit();		
	return true;		
	}

}

function fun_promotion()
{
  with(document.frmuserbilldetails)
	{
	   if(trimAll(text_promo.value)=="")
		{
          alert("Please enter the promotional code");
		  text_promo.focus();
		  return false;
		}
		else
		{
			hid_order_summary.value="promotion";
			submit();
		}
	}
}

function final_summary(list_all)
{
	with(document.ordersummary)
	{	
		var totalcnt=document.getElementById("total_order").value;
		for(var num=1;num<totalcnt;num++)
		{
		document.getElementById("month_"+num).disabled=false;
		document.getElementById("year_"+num).disabled=false;	
		}
        if(list_all=="")
		{
			if(hid_mlist.value=='' && hid_ylist.value=='' && hid_pack.value=='' && hid_yearpack.value=='' && hid_mlist_email.value=='')
			{
				alert("Please select a list to subscribe");
				return false;
			}		
		
	    }
		hid_order_summary.value="subscribe";	
		submit();
		return true;	
      }
}
function funuserbilldetails()
{
with(document.frmuserbilldetails)
	{
		var totalcnt=document.getElementById("total_order").value;
		if(trimAll(first_name.value)=="")
		{
		alert("Please enter your first name");
		first_name.focus();
		return false;
		}		
		else if(trimAll(last_name.value)=="")
		{
		alert("Please enter your last name");
		last_name.focus();
		return false;
		}
		else if(trimAll(email.value)=="")
		{
		alert("Please enter your email address");
		email.focus();
		return false;
		}
		else if(!validateEmail(email.value))
		{
		alert("Please enter valid email address");
		email.focus();
		return false;
		}
		else if(trimAll(telephone.value)=="")
		{
		alert("Please enter your telephone number");
		telephone.focus();
		return false;
		}
		else if(trimAll(password.value)=="")
		{
		alert("Please enter your password");
		password.focus();
		return false;
		}
		else if(trimAll(password2.value)=="")
		{
		alert("Please enter your confirmation password");
		password2.focus();
		return false;
		}
		else if(password2.value!=password.value)
		{
		alert("Confirmation passwrod is mismatch with your password");
		password.focus();
		return false;
		}
		else if(trimAll(pass_hint.value)=="")
		{
		alert("Please enter your pasword hint");
		pass_hint.focus();
		return false;
		}
		else if(trimAll(name.value)=="")
		{
		alert("Please enter the name of your card");
		name.focus();
		return false;
		}
		else if(trimAll(street_1.value)=="")
		{
		alert("Please enter your address");
		street_1.focus();
		return false;
		}
		else if(trimAll(city.value)=="")
		{
		alert("Please enter your city");
		city.focus();
		return false;
		}
		else if(trimAll(state.value)=="")
		{
		alert("Please enter your state");
		state.focus();
		return false;
		}
		else if(trimAll(postcode.value)=="")
		{
		alert("Please enter your postcode");
		postcode.focus();
		return false;
		}
		else if(trimAll(country_id.value)=="")
		{
		alert("Please select your country");
		country_id.focus();
		return false;
		}
		else if(trimAll(cc_num_trunc.value)=="")
		{
		alert("Please enter your credit card number");
		cc_num_trunc.focus();
		return false;
		}
		else if(trimAll(expiration_month.value)=="")
		{
		alert("Please select the expiration month");
		expiration_month.focus();
		return false;
		}
		else if(trimAll(expiration_year.value)=="")
		{
		alert("Please select the expiration year");
		expiration_year.focus();
		return false;
		}
		else if(trimAll(cvv.value)=="")
		{
		alert("Please enter the CVV");
		cvv.focus();
		return false;
		}
		else if(trimAll(wyk.value)=="")
		{
		alert("Where did you here about us?");
		wyk.focus();
		return false;
		}
		else if(terms.checked==false)
		{
			alert("To continue, please agree the Terms & Conditions");
			terms.focus();
			return false;
		}
		else
		{
			for(var num=1;num<totalcnt;num++)
			{
				document.getElementById("month_"+num).disabled=false;
				document.getElementById("year_"+num).disabled=false;	
			}
			hid_sub_form.value="usersubscribe";
			submit();
			return true;
		}
	}
}

function  fun_singleclick_checkbox()
{
with(document.fullselection)
	{	
		t_len = total_chk.value;
		check_sel=false;

		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("month_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}		
		if(check_sel==false)
		{
			alert("Please select a list to subscribe");
			return false;
		}
		else
		{
			fulllist.value="lists_alacarte";
			submit();		
			return true;
		}
	}

}

function fun_exportCSV(formname)
{
	with(document.forms[formname])
	{
		
		if( confirm("Are you sure want to export the user details?"))
		{
			hid_export.value="export";
			submit();
			return true;
		}
		else
			return false;
		
	}
}
function fun_ArchiveexportCSV(formname)
{
	with(document.forms[formname])
	{
		
		if( confirm("Are you sure want to export the archive user details?"))
		{
			hid_export.value="export";
			submit();
			return true;
		}
		else
			return false;
		
	}
}
function addcontactvalidation()
{
	with(document.frmadddcontact)
	{
		if(grouplist.value=="" && trimAll(group.value)=="")
		{
			alert("Please select a group");
			grouplist.focus();
			return false;
		}
		else if(grouplist.value!="" && trimAll(group.value)!="")
		{
			alert("Please choose any one option");
			return false;
		}
		else if(grouplist.value=="" && trimAll(group.value)!="" && trimAll(description.value)=="")
		{
			alert("Please enter description");
			description.focus();
			description.value="";
			return false;
		}
		else if(trimAll(description.value)!="" && trimAll(group.value)=="")
		{
			alert("Please choose any one option");
			return false;
		}
		else
		{
			submit();
		}
	}
}
function concierge_validation()
{
	with(document.frm_concierge)
	{
		if(trimAll(firstname.value)=='')
		{
			alert('Please enter your first name');
			firstname.focus();
			firstname.value="";
			return false;
		}
		else if(trimAll(lastname.value)=='')
		{
			alert('Please enter your last name');
			lastname.focus();
			lastname.value="";
			return false;
		}
		else if(trimAll(emailaddress.value)=='')
		{
			alert('Please enter your email address');
			emailaddress.focus();
			emailaddress.value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('emailaddress').value))
		{
			alert("Please enter valid email address");
			document.getElementById('emailaddress').focus();
			return false;
		}
		else if((trimAll(contact1.value)=='') && (trimAll(contact2.value)=='') && (trimAll(contact3.value)==''))
		{
			alert("Please enter at least one contact");
			document.getElementById('contact1').focus();
			return false;
		}
		else
			submit();
	}
}
function validatecontacts(mode)
{
	with(document.frm_contact)
	{
		var	totallist="";
		var checked="no";
		for(var i=1;i<=listcount.value;i++)
		{
			var checkbox="check"+i;
			if(document.getElementById(checkbox).checked == true)
			{
				checked="yes";
				if(totallist=="")
				{
					totallist	=	document.getElementById(checkbox).value;
				}
				else
				{
					totallist	=	totallist+","+document.getElementById(checkbox).value;
				}
			}
		}
		document.getElementById("multiplehdn").value=totallist;
		if(trimAll(firstname.value)=='')
		{
			alert('Please enter First Name');
			firstname.focus();
			firstname.value="";
			return false;
		}
		else if(trimAll(lastname.value)=='')
		{
			alert('Please enter Last Name');
			lastname.focus();
			lastname.value="";
			return false;
		}
		else if(trimAll(company.value)=='')
		{
			alert('Please enter Company Name');
			company.focus();
			company.value="";
			return false;
		}
		else if(trimAll(email.value)=='')
		{
			alert('Please enter Email Address');
			email.focus();
			email.value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('email').value))
		{
			alert("Please enter valid Email Address");
			document.getElementById('email').focus();
			return false;
		}
		else if(trimAll(telephone.value)=='')
		{
			alert('Please enter Telephone Number');
			telephone.focus();
			telephone.value="";
			return false;
		}
		else if(checked=="no")
		{
			alert("Please select at least one list");
			check1.focus();
			return false;
		}
		else if(mode=='add')
		{
			hdnmode.value="add";
			submit();
			return true;
		}
		else if(mode=='edit')
		{
			hdnmode.value="edit";
			submit();
			return true;
		}
		else if(mode=='accept')
		{
			hdnmode.value="accept";
			submit();
			return true;
		}
		else if(mode=='reject')
		{
			hdnmode.value="reject";
			submit();
			return true;
		}
	}
}
function MultipleSel()
{
	with(document.frm_contact)
	{
		var user=document.getElementById("listtype");
		var r = "";
		for (var i=0; i<user.options.length; i++)
		{
			if (user.options[i].selected)
			{
				r = r+user.options[i].value+",";							
			}
		}
		var multiurl=r.substr(0,r.length-1);
		document.getElementById("hdndata").value="yes";
		document.getElementById("multiplehdn").value=multiurl;
	}
}
function validatehearaboutus(mode)
{
	with(document.frmhearaboutus)
	{
		
		if(trimAll(source.value)=='')
		{
			alert('Please enter the source name');
			source.focus();
			source.value="";
			return false;
		}
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function validategroup(mode,groupid)
{
	with(document.frm_contactlist)
	{
		if(trimAll(group.value)=='')
		{
			alert('Please enter Group Name');
			group.focus();
			group.value="";
			return false;
		}
		else if(trimAll(description.value)=='')
		{
			alert('Please enter the Description');
			description.focus();
			description.value="";
			return false;
		}
		else if(mode=='add')
		{
			hdnmode.value="add";
			submit();
			return true;
		}
		else if(mode=='edit')
		{
			hdnmode.value=groupid;
			submit();
			return true;
		}
	}
}
function filtervalidation()
{
	with(document.frm_contactlist)
	{
		if(trimAll(listfilter.value)=="" || trimAll(listfilter.value)=="Enter Contact Name Here")
		{
			alert('Please enter the search key');
			listfilter.focus();
			listfilter.value="";
			return false;
		}
		else
		{
			hdnfilter.value="yes";
			submit();
		}
	}
}
function validatenews(mode)
{
	with(document.frmnews)
	{
		var file=trimAll(news_image.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();

		/*var file1=trimAll(news_image1.value);
		var ary1 = file1.split(".");
		var ext1 = ary1[ary1.length-1].toLowerCase();*/

		if(trimAll(title.value)=='')
		{
			alert('Please enter the Title for News');
			title.focus();
			return false;
		}
		else if(trimAll(byline.value)=='')
		{
			alert('Please enter the Author for News');
			byline.focus();
			return false;
		}
		/*else if(trimAll(sort_order.value)=='')
		{
			alert('Please enter the sort order for news');
			sort_order.focus();
			return false;
		}
		else if(!validateNumeric(sort_order.value))
		{
			alert('Please enter the numeric value for sort order');
			sort_order.focus();
			return false;
		}*/
		if(mode=='add')
		{
			if(news_image.value=='')
			{
			alert("Please select image file1");				
			document.getElementById('news_image').focus();
			return false;
			}
			/*else if(news_image1.value=='')
			{
			alert("Please select image file2");				
			news_image1.focus();
			return false;
			}*/
			else if((!((ext=="jpg")||(ext=="gif")||(ext=="jpeg"))) && (news_image.value!='')) 
			{
				alert("You have selected a '."+ ext +"' file in image file1, Please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
				news_image.focus();
				return false;
			}
			/*else if((!((ext1=="jpg")||(ext1=="gif")||(ext1=="jpeg"))) && (news_image1.value!='')) 
			{
			alert("You have selected a '."+ ext1 +"' file in image file2, please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
			news_image1.focus();
			return false;
			}*/
		}		
		hidaction.value=mode;
		submit();
		return true;
	}
}
function validatepromotional(mode)
{
	with(document.frmpromotional)
	{
		if(trimAll(promotional.value)=='')
		{
			alert('Please enter the Promotional Code');
			promotional.focus();
			promotional.value="";
			return false;
		}
		else if(trimAll(usecount.value)=='')
		{
			alert('Please enter Maximum Use Count');
			usecount.focus();
			usecount.value="";
			return false;
		}
		else if(!validateNumeric(usecount.value))
		{
			alert('Please enter numeric value for Maximum Use Count');
			usecount.focus();
			return false;
		}
		else if(trimAll(exp_date.value)=='')
		{
			alert('Please enter Expiry Date');
			exp_date.focus();
			exp_date.value="";
			return false;
		}
		else if((trimAll(percentage.value)=='') && (trimAll(usd.value)==''))
		{
			alert('Please Enter Amount in Percentage or USD');
			return false;
		}
		else if((trimAll(percentage.value)!='') && (trimAll(usd.value)!=''))
		{
			alert('Please enter Percentage or USD');
			return false;
		}
		else if((trimAll(percentage.value)!='') && !validateNumeric(percentage.value))
		{
			alert('Please enter numeric value for Percentage');
			percentage.focus();
			return false;
		}
		else if((trimAll(percentage.value)!='') && percentage.value>100)
		{
			alert('Please enter the value less than hundred');
			percentage.focus();
			return false;
		}
		else if((trimAll(usd.value)!='') && !validateNumeric(usd.value))
		{
			alert('Please enter numeric value for USD');
			usd.focus();
			return false;
		}
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function validateindeximages(mode)
{
	with(document.frmindeximages)
	{
		var start1 = startdate.value;
		var aryim1 = start1.split("-");
		var year1 = aryim1[2];
		var month1= aryim1[0];
		var date1 = aryim1[1];
		startdate1 = year1+"-"+month1+"-"+date1;

		var end1 = enddate.value;
		var aryim2 = end1.split("-");
		var year2 = aryim2[2];
		var month2 = aryim2[0];
		var date2 = aryim2[1];
		enddate1 = year2+"-"+month2+"-"+date2;

		var file1=trimAll(indeximage1.value);
		var ary1 = file1.split(".");
		var ext1 = ary1[ary1.length-1].toLowerCase();

		var file2=trimAll(indeximage2.value);		
		var ary2 = file2.split(".");
		var ext2 = ary2[ary2.length-1].toLowerCase();

		var file3=trimAll(indeximage3.value);		
		var ary3 = file3.split(".");
		var ext3 = ary3[ary3.length-1].toLowerCase();

		var file4=trimAll(indeximage4.value);		
		var ary4 = file4.split(".");
		var ext4 = ary4[ary4.length-1].toLowerCase();

		if(mode=="add")
		{
			if((indeximage1.value==''))
			{
				alert("Please select image file1");				
				indeximage1.focus();
				return false;
			}
			else if((indeximage2.value==''))
			{
				alert("Please select image file2");				
				indeximage2.focus();
				return false;
			}
			else if((indeximage3.value==''))
			{
				alert("Please select image file3");				
				indeximage3.focus();
				return false;
			}
			else if((indeximage4.value==''))
			{
				alert("Please select image file4");				
				indeximage4.focus();
				return false;
			}
		}

		if((ext1!="gif") && (indeximage1.value!='')) 
		{
			alert("You have selected a '."+ ext1 +"' file in image file1, please Select the file of type 'gif'");				
			indeximage1.focus();
			return false;
		}
		else if((ext2!="gif") && (indeximage2.value!='')) 
		{
			alert("You have selected a '."+ ext2 +"' file in image file2, please Select the file of type 'gif'");				
			indeximage2.focus();
			return false;
		}
		else if((ext3!="gif") && (indeximage3.value!='')) 
		{
			alert("You have selected a '."+ ext3 +"' file in image file3, please Select the file of type 'gif'");				
			indeximage3.focus();
			return false;
		}
		else if((ext4!="gif") && (indeximage4.value!='')) 
		{
			alert("You have selected a '."+ ext4 +"' file in image file4, please Select the file of type 'gif'");				
			indeximage4.focus();
			return false;
		}
		else if(startdate.value=="") 
		{
			alert("Please enter the starting date");
			startdate.focus();
			return false;
		}
		else if(enddate.value=="") 
		{
			alert("Please enter the ending date");				
			enddate.focus();
			return false;
		}
		else if(enddate1 < startdate1)
		{
			alert("Start date should be less than end date");
			return false;
		}
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function fun_gen_search()
{
	document.getElementById('gen1').style.display="none";
	document.getElementById('gen2').style.display="";
	document.getElementById('tot1').style.display="";
	document.getElementById('tot2').style.display="none";

	document.getElementById('general_search').style.display="";
	document.getElementById('adv_search').style.display="none";
}
function fun_adv_search()
{
	document.getElementById('gen1').style.display="";
	document.getElementById('gen2').style.display="none";
	document.getElementById('tot1').style.display="none";
	document.getElementById('tot2').style.display="";

	document.getElementById('adv_search').style.display="";
	document.getElementById('general_search').style.display="none";
}
function validatetestimonial(mode)
{
	with(document.frmtestimonial)
	{
		file=trimAll(test_image.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();

		if(trimAll(title.value)=='')
		{
			alert('Please enter title for testimonial');
			title.focus();
			title.value="";
			return false;
		}
		else if((!((ext=="jpg")||(ext=="gif")||(ext=="jpeg"))) && (test_image.value!='')) 
		{
			alert("You have selected a '."+ ext +"' file, please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
			news_image.focus();
			return false;
		}		
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function validateadvisors(mode)
{
	with(document.frmadvisors)
	{
		file=trimAll(test_image.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();

		if(trimAll(title.value)=='')
		{
			alert('Please enter title');
			title.focus();
			title.value="";
			return false;
		}
		else if((!((ext=="jpg")||(ext=="gif")||(ext=="jpeg"))) && (test_image.value!='')) 
		{
			alert("You have selected a '."+ ext +"' file, please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
			news_image.focus();
			return false;
		}
	
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function validatetrailprice(mode)
{
	with(document.frmtrialprice)
	{
		if(trimAll(trialprice.value)=='')
		{
			alert('Please enter trial price');
			trialprice.focus();
			trialprice.value="";
			return false;
		}
		else if((trimAll(trialprice.value)!='') && !validateNumeric(trialprice.value))
		{
			alert('Please enter numeric value');
			trialprice.focus();
			return false;
		}
		else if((trimAll(trialprice.value)!='') && trialprice.value>100)
		{
			alert('Please enter the value less than hundred');
			trialprice.focus();
			return false;
		}
		else
		{
			hidaction.value=mode;
			submit();
			return true;
		}
	}
}
function validateTinyMCEEditor()
{
 tinyMCE.triggerSave(true,true); 
 var mytextarea = tinyMCE.getContent();
 if(mytextarea == "") 
 {        
 return true;   
 }  
}


function toolTip1(text,me) 
{
	with(document.frm_contactlist)
	{
		theObj=me;
		theObj.onmousemove=updatePos1;
		document.getElementById('toolTipBox').innerHTML=text;
		document.getElementById('toolTipBox').style.display="block";
		window.onscroll=updatePos1;
	}
}
function updatePos1() 
{
	with(document.frm_contactlist)
	{
		var ev=arguments[0]?arguments[0]:event;
		var x=ev.clientX;
		var y=ev.clientY;
		diffX=24;
		diffY=0;
		document.getElementById('toolTipBox').style.top = y-2+diffY+document.body.scrollTop+ "px";
		document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
		theObj.onmouseout=hideMe1;
	}
}
function hideMe1() 
{
	with(document.frm_contactlist)
	{
		document.getElementById('toolTipBox').style.display="none";
	}
}


function RecordResolution()
{
	var width	=	screen.width;
	var height	=	screen.height;
	if(width<=1024 && height<=768)
	{
		document.getElementById('imagepos').className="style_list_pos";
	}
	else if((width>1024 && width<1680) && (height>768 && height<1050))
	{
		document.getElementById('imagepos').className="style_list_pos1";
	}
	else if(width>=1680 && height>=1050)
	{
		document.getElementById('imagepos').className="style_list_pos2";
	}
}

function  fun_emailmarket()
{
with(document.emailmarketing)
	{	
		t_len = total_chk.value;
		check_sel=false;

		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("emailmonth_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}		
		if(check_sel==false)
		{
			alert("Please select a list to subscribe");
			return false;
		}
		else
		{
			fulllist.value="email_market";
			submit();		
			return true;
		}
	}

}

function  fun_emailmarket_checkout()
{
with(document.ordersummary)
	{	
		t_len = total_box.value;
		check_sel=false;

		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("emailmonthcheck_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}		
		if(check_sel==false)
		{
			alert("Please select a email list to subscribe");
			return false;
		}
		else
		{
			fulllist.value="email_market_checkout";
			submit();		
			return true;
		}
	}

}

function fun_user_validation()
{
	with(document.frm_edit_userdetails)
	{
		if(trimAll(document.getElementById('first_name').value)=="")
		{
			alert("Please enter the first name");
			document.getElementById('first_name').focus();
			document.getElementById('first_name').value="";
			return false;
		}
		else if(trimAll(document.getElementById('last_name').value)=="")
		{
			alert("Please enter the last name");
			document.getElementById('last_name').focus();
			document.getElementById('last_name').value="";
			return false;
		}		
		else if(trimAll(document.getElementById('email').value)=="")
		{
			alert("Please enter the email address");
			document.getElementById('email').focus();
			document.getElementById('email').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('email').value))
		{
			alert("Please enter valid email address");
			document.getElementById('email').focus();
			return false;
		}
		else if(trimAll(document.getElementById('telephone').value)=="")
		{
			alert("Please enter the telephone number");
			document.getElementById('telephone').focus();
			document.getElementById('telephone').value="";
			return false;
		}		
		else
		{
			document.getElementById('hdn_edit_user').value="edituser";
			submit();
		}
	}
}
function email_validate_top()
{
formname="frmImportCsv";
	with(document.forms[formname])	
	{
		var file=trimAll(csvfile.value);
		if(file=='')
			file=hid_dig_img.value;
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();
		t_len = total_group.value;
		check_sel=false;
		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("ddlList_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}
		if(trimAll(document.getElementById('email_name').value)=="")
		{
			alert("Please enter the email name");
			document.getElementById('email_name').focus();
			document.getElementById('email_name').value="";
			return false;
		}
		else if(check_sel==false)
		{
		alert("Please select any of the group");
		ddlList_1.focus();
		return false;
		}
		else if(csvfile.value=='')
		{
			alert("Please browse your own email design");
			document.getElementById('csvfile').focus();
			document.getElementById('csvfile').value="";
			return false;
		}
		else if((!((ext=="jpg")||(ext=="gif")||(ext=="jpeg"))) && (csvfile.value!='')) 
		{
		alert("You have selected a '."+ ext +"' file in image file, please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
		csvfile.focus();
		return false;
		}
		else if(trimAll(document.getElementById('subject1').value)=="")
		{
			alert("Please enter the subject");
			document.getElementById('subject1').focus();
			document.getElementById('subject1').value="";
			return false;
		}		
		else
		{
			action="email-settings.php";
			hid_email_action.value="sendemail";
			submit();
		}
	}
}
function email_validate()
{
formname="frmImportCsv";
	with(document.forms[formname])	
	{
		t_len = total_group.value;
		check_sel=false;
		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("ddlList_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}
		if(trimAll(document.getElementById('email_name').value)=="")
		{
			alert("Please enter the email name");
			document.getElementById('email_name').focus();
			document.getElementById('email_name').value="";
			return false;
		}
		else if(check_sel==false)
		{
		alert("Please select any of the group");
		ddlList_1.focus();
		return false;
		}		
		else if(trimAll(document.getElementById('subject').value)=="")
		{
			alert("Please enter the subject");
			document.getElementById('subject').focus();
			document.getElementById('subject').value="";
			return false;
		}
		else if(validateTinyMCEEditor(message))
		{
			alert('Please enter message');
			message.focus();
			message.value="";
			return false;
		}
		else
		{
			action="email-settings.php";
			hid_email_action.value="sendemail";
			submit();
		}
	}
}
function fnShowPreview_top()
{ 
	formname="frmImportCsv";

	with(document.forms[formname])	
	{
		var file=trimAll(csvfile.value);	
		if(file=='')
			file=hid_dig_img.value;
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();
		t_len = total_group.value;
		check_sel=false;
		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("ddlList_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}
		if(trimAll(document.getElementById('email_name').value)=="")
		{
			alert("Please enter the email name");
			document.getElementById('email_name').focus();
			document.getElementById('email_name').value="";
			return false;
		}
		else if(check_sel==false)
		{
		alert("Please select any of the group");
		ddlList_1.focus();
		return false;
		}			
		else if(csvfile.value=='')
		{
			alert("Please browse your own email design");
			document.getElementById('csvfile').focus();
			document.getElementById('csvfile').value="";
			return false;
		}
		else if((!((ext=="jpg")||(ext=="gif")||(ext=="jpeg"))) && (csvfile.value!='')) 
		{
		alert("You have selected a '."+ ext +"' file in image file, please Select the file of type 'jpg' or 'gif' or 'jpeg'");				
		csvfile.focus();
		return false;
		}
		else if(trimAll(document.getElementById('subject1').value)=="")
		{
			alert("Please enter the subject");
			document.getElementById('subject1').focus();
			document.getElementById('subject1').value="";
			return false;
		}		
		else
		{
		hid_email_action.value="";
		windowName = "PreviewEmail";
		target = windowName;
		action="popupemail.php";
		open ('',windowName,'top=110,left=110,resizable=no,scrollbars=yes');     
		submit(); 
		target=""; 
		}
	}
}
function fnShowPreview()
{ 
	formname="frmImportCsv";
	with(document.forms[formname])	
	{
		t_len = total_group.value;
		check_sel=false;
		for(i=1;i<=t_len-1;i++)
		{
			if(document.getElementById("ddlList_"+i).checked==true)
			{
				check_sel=true;
				break;
			}
		}
		if(trimAll(document.getElementById('email_name').value)=="")
		{
			alert("Please enter the email name");
			document.getElementById('email_name').focus();
			document.getElementById('email_name').value="";
			return false;
		}
		else if(check_sel==false)
		{
		alert("Please select any of the group");
		ddlList_1.focus();
		return false;
		}			
		else if(trimAll(document.getElementById('subject').value)=="")
		{
			alert("Please enter the subject");
			document.getElementById('subject').focus();
			document.getElementById('subject').value="";
			return false;
		}
		else if(validateTinyMCEEditor(message))
		{
			alert('Please enter message');
			message.focus();
			message.value="";
			return false;
		}
		else
		{
		hid_email_action.value="";
		windowName = "PreviewEmail";
		target = windowName;
		action="popupemail.php";
		open ('',windowName,'top=110,left=110,width=600,height=550,resizable=no,scrollbars=yes');     
		submit(); 
		target=""; 
		}
	}
}
function reportfiltervalidation()
{
	with(document.reportform)
	{
		if(yearselect.value=="" && monthselect.value=="")
		{
			alert("Please select at least one filter option");
			return false;
		}
		else if(yearselect.value=="" && monthselect.value!="")
		{
			alert("Please select year value");
			yearselect.focus();
			return false;
		}
		else
			exporthdn.value="";
			submit();
	}
}
function exportvalidation()
{
	with(document.reportform)
	{
		if(confirm("Do you really want to export the details?"))
		{
			exporthdn.value="export";
			submit();
		}
	}
}

function funimport_mycontact()
{
	with(document.frmImport_mycontactCsv)
	{
		file=trimAll(csvfile.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();
		if(trimAll(document.getElementById('csvfile').value)=="")
		{
			alert("Please browse your CSV to import the contacts");			
			return false;
		}	
		else if((!((ext=="csv")||(ext=="CSV"))) && (csvfile.value!='')) 
		{
		alert("You have selected a '."+ ext +"' file, please Select the file of type 'CSV'");				
		csvfile.focus();
		csvfile.value="";
		return false;
		}	
		else
		{
			document.getElementById('hdn_import').value="mycontacts";
			submit();
		}
	}
}
function validatenewsletter(mode)
{
	with(document.frmnewsletter)
	{
		if(trimAll(newsusers.value)=="")
		{
			alert("Please select at least one user type");
			newsusers.focus();
			return false;
		}
		else if(trimAll(fromname.value)=="")
		{
			alert("Please enter from name");
			fromname.focus();
			fromname.value=="";
			return false;
		}
		else if(trimAll(fromemail.value)=="")
		{
			alert("Please enter from email");
			fromemail.focus();
			fromemail.value=="";
			return false;
		}
		else if(!validateEmail(document.getElementById('fromemail').value))
		{
			alert("Please enter valid email address");
			document.getElementById('fromemail').focus();
			return false;
		}
		else if(trimAll(subject.value)=="")
		{
			alert("Please enter subject");
			subject.focus();
			subject.value=="";
			return false;
		}	
		if(contestradio[0].checked==true)
		{
			if(contest.value=="")
			{
				alert("Please select a contest");
				contest.focus();
				return false;
			}
		}
		hidaction.value=mode;
		submit();
		return true;

	}
}
function projectfiltervalidation()
{
	with(document.frm_projecthome)
	{
		if(trimAll(projectfilter.value)=="" || trimAll(projectfilter.value)=="Enter Project Name Here")
		{
			alert('Please enter the search key');
			projectfilter.focus();
			projectfilter.value="";
			return false;
		}
		else
		{
			hdnfilter.value="yes";
			submit();
		}
	}
}
function validateprojectadd(mode,projectid)
{
	with(document.frm_projecthome)
	{
		var start = startdate.value;
		var ary = start.split("-");
		var year = ary[2];
		var month = ary[0];
		var date = ary[1];
		startdate1 = year+"-"+month+"-"+date;

		var end = enddate.value;
		var ary = end.split("-");
		var year = ary[2];
		var month = ary[0];
		var date = ary[1];
		enddate1 = year+"-"+month+"-"+date;

		if(trimAll(project.value)=='')
		{
			alert('Please enter project name');
			project.focus();
			project.value="";
			return false;
		}
		else if(trimAll(description.value)=='')
		{
			alert('Please enter description');
			description.focus();
			description.value="";
			return false;
		}
		else if(startdate.value=='')
		{
			alert('Please enter start date');
			startdate.focus();
			startdate.value="";
			return false;
		}
		else if(enddate.value=='')
		{
			alert('Please enter end date');
			enddate.focus();
			enddate.value="";
			return false;
		}
		else if(enddate1 < startdate1)
		{
			alert("Start date should be less than end date");
			return false;
		}
		else if(mode=='add')
		{
			hdnmode.value="add";
			submit();
			return true;
		}
		else if(mode=='edit')
		{
			hdnmode.value=projectid;
			submit();
			return true;
		}
	}
}

function toolTip(text,me) 
{
	with(document.frm_projecthome)
	{
		theObj=me;
		theObj.onmousemove=updatePos;
		document.getElementById('toolTipBox').innerHTML=text;
		document.getElementById('toolTipBox').style.display="block";
		window.onscroll=updatePos;
	}
}
function updatePos() 
{
	with(document.frm_projecthome)
	{
		var ev=arguments[0]?arguments[0]:event;
		var x=ev.clientX;
		var y=ev.clientY;
		diffX=24;
		diffY=0;
		document.getElementById('toolTipBox').style.top = y-2+diffY+document.body.scrollTop+ "px";
		document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
		theObj.onmouseout=hideMe;
	}
}
function hideMe() 
{
	with(document.frm_projecthome)
	{
		document.getElementById('toolTipBox').style.display="none";
	}
}

function updateprojectdetails(type)
{
	with(document.frm_guestlist)
	{
		var start = startdate.value;
		var ary = start.split("-");
		var year = ary[2];
		var month = ary[0];
		var date = ary[1];
		startdate1 = year+"-"+month+"-"+date;

		var end = enddate.value;
		var ary = end.split("-");
		var year = ary[2];
		var month = ary[0];
		var date = ary[1];
		enddate1 = year+"-"+month+"-"+date;

		if(type=='name')
		{
			if(trimAll(projectname.value)=="")
			{
				alert("Please enter the project name");
				projectname.value="";
				projectname.focus();
				return false;
			}
		}
		if(type=='projectdate')
		{
			var pro_start=startdate.value;
			var pro_end=enddate.value;
			if(startdate.value=="")
			{
				alert("Please enter start date");
				startdate.value="";
				startdate.focus();
				return false;
			}		
			if(enddate.value=="")
			{
				alert("Please enter end date");
				enddate.value="";
				enddate.focus();
				return false;
			}
			/*if(compare_todayDate(pro_start)==false)
			{
			alert('Entered start date should not be is lower than today\'s date');
			return false;
			}
			if(compare_todayDate(pro_start)==false)
			{
			alert('Entered start date should not be is lower than today\'s date');
			return false;
			}	
			if(compare_todayDate(pro_end)==false)
			{
			alert('Entered start date should not be is lower than today\'s date');
			return false;
			}	*/
			if(enddate1 < startdate1)
			{
				alert("Start date should be less than end date");
				return false;
			}
		}
		if(type=='note')
		{
			if(trimAll(description.value)=="")
			{
				alert("Please enter notes");
				description.value="";
				description.focus();
				return false;
			}
		}
		action="tcl-project-detail.php";
		hdnsamplecsv.value="";
		//alert(hid_project_id.value);
		hdnmode.value='editprojectdetails';
		hdntype.value=type;
		submit();
	}
}
function email_settings()
{
	formname="frm_email_settings";
	with(document.forms[formname])	
	{
		if(trimAll(document.getElementById('from_name').value)=="")
		{
			alert("Please enter the from name");
			document.getElementById('from_name').focus();
			document.getElementById('from_name').value="";
			return false;
		}
		else if(trimAll(document.getElementById('company_name').value)=="")
		{
			alert("Please enter the company name");
			document.getElementById('company_name').focus();
			document.getElementById('company_name').value="";
			return false;
		}
		else if(trimAll(document.getElementById('address').value)=="")
		{
			alert("Please enter your address");
			document.getElementById('address').focus();
			document.getElementById('address').value="";
			return false;
		}
		else if(trimAll(document.getElementById('city').value)=="")
		{
			alert("Please enter your city");
			document.getElementById('city').focus();
			document.getElementById('city').value="";
			return false;
		}
		else if(trimAll(document.getElementById('state').value)=="")
		{
			alert("Please select your state");
			document.getElementById('state').focus();
			document.getElementById('state').value="";
			return false;
		}
		else if(trimAll(document.getElementById('zipcode').value)=="")
		{
			alert("Please enter the postal code");
			document.getElementById('zipcode').focus();
			document.getElementById('zipcode').value="";
			return false;
		}
		else if(trimAll(document.getElementById('country').value)=="")
		{
			alert("Please select your country");
			document.getElementById('country').focus();
			document.getElementById('country').value="";
			return false;
		}		
		else
		{
			action="email-sendoptions.php";
			hid_email_action.value="email_settings";
			submit();
		}
	}
}
function email_approvals()
{
	formname="frm_email_approval";
	with(document.forms[formname])	
	{
		if(document.getElementById("codn_1").checked==false || document.getElementById("codn_2").checked==false ||document.getElementById("codn_3").checked==false || document.getElementById("codn_4").checked==false ||document.getElementById("codn_5").checked==false || document.getElementById("codn_6").checked==false)
		{
			alert("You must agree these all email marketing approvals in order to proceed!!");
			return false;
		}
		else
		{
			action="email-preview.php";
			hid_email_action.value="email_final";
			submit();
		}
	}
}


function fun_addtask()
{
	with(document.frm_guestlist)
	{
		browser = navigator.appName;
		ie = "Microsoft Internet Explorer";
		os = navigator.platform;
		if (browser ==  ie)
		{
			var boxHeight = document.getElementById("contactlistdiv").offsetHeight;
			var totheight=boxHeight+30;
		}
		else
		{
			var boxHeight = document.getElementById("contactlistdiv").clientHeight;
			var totheight=boxHeight+16;
		}
		document.getElementById('totaldiv').style.height=totheight;

		document.getElementById('totaldiv').className="totaldiv_bg";
		document.getElementById('addtask').className="addtask_bg";
		document.getElementById('addtask').style.display="";
		var projectid	=	hdnprojectid.value;
		task.value="";
		duedate.value="";
		priority.value="";
		notes.value="";
		hid_action_mode.value="";
	}
}
function canceladtask()
{
	document.getElementById('addtask').style.display="none";
	document.getElementById('totaldiv').className="";
	document.getElementById('totaldiv').style.height="";
}
function addtaskvalidation()
{
	with(document.frm_guestlist)
	{
		var enterduedate=duedate.value;
		if(trimAll(task.value)=='')
		{
			alert('Please enter task name');
			task.focus();
			task.value="";
			return false;
		}
		else if(trimAll(duedate.value)=='')
		{
			alert('Please enter Due Date');
			duedate.focus();
			duedate.value="";
			return false;
		}
		else if(!enterduedate.match(/^(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])\-([0-9]{4})/))
		{
		alert('Entered Due Date format is wrong.Please follow this format (MM-DD-YYYY)');
		duedate.focus();	
		return false;
		}
		else if(compare_todayDate(enterduedate)==false)
		{
		alert('Entered start date should not be is lower than today\'s date');
		return false;
		}
		else if(trimAll(priority.value)=='')
		{
			alert('Please enter priority');
			priority.focus();
			priority.value="";
			return false;
		}
		else
		{
			document.getElementById('addtask').style.display="none";
			document.getElementById('totaldiv').className="";
			hdnmode.value='addtask';
			action="tcl-project-detail.php";
			submit();
			target="";
			return true;
		}
	}
}

function fun_addcontacts(mode)
{
	with(document.frm_guestlist)
	{
		browser = navigator.appName;
		ie = "Microsoft Internet Explorer";
		os = navigator.platform;

		if (browser ==  ie)
		{
			for(var i=1;i<=tot_guests.value;i++)
			{
				var guest_id = "rsvp"+i;
				document.getElementById(guest_id).style.display='none';
			}

			for(var i=1;i<=tot_press.value;i++)
			{
				var press_id = "rsvppress"+i;
				document.getElementById(press_id).style.display='none';
			}

			document.getElementById('addcontactstable').style.width='90%';
			var boxHeight = document.getElementById("contactlistdiv").offsetHeight;
			var boxWidth = document.getElementById("contactlistdiv").offsetWidth;
			var totheight=boxHeight+30;
			var totwidth=boxWidth+30;
		}
		else
		{
			document.getElementById('addcontactstable').style.width='65%';
			var boxHeight = document.getElementById("contactlistdiv").clientHeight;
			var boxWidth = document.getElementById("contactlistdiv").clientWidth;
			var totheight=boxHeight+15;
			var totwidth=boxWidth+104;
		}
		document.getElementById('totaldiv').style.height=totheight;
		document.getElementById('totaldiv').style.width=totwidth;
		document.getElementById('totaldiv').className="totaldiv_bg";
		document.getElementById('addcontacts').className="addtask_bg1";
		document.getElementById('addcontacts').style.display="";

		if(mode!='addcontacts')
			document.getElementById('rsvptr').style.display="";
		else
			document.getElementById('rsvptr').style.display="none";
		hdnmode.value=mode;
		var projectid	=	hdnprojectid.value;
		hdnaddcontacts.value='yes';
		hdnsamplecsv.value="";

		firstname.value="";
		lastname.value="";
		contactcompany.value="";
		title.value="";
		representation.value="";
		contactemail.value="";
		website.value="";
		contactphone.value="";
		fax.value="";
		address1.value="";
		address2.value="";
		city.value="";
		state.value="";
		zip.value="";
		country.value="";
		contactnotes.value="";
		rsvp_contact.value="";
	}
}
function fun_addfulldetail()
{
	with(document.frm_contactlist)
	{
		browser = navigator.appName;
		ie = "Microsoft Internet Explorer";
		os = navigator.platform;
		if (browser ==  ie)
		{
			var boxHeight = document.getElementById("contactlistdiv").offsetHeight;
			var totheight=boxHeight+30;
		}
		else
		{
			var boxHeight = document.getElementById("contactlistdiv").clientHeight;
			var totheight=boxHeight+16;
		}
		document.getElementById('totaldiv').style.height=totheight;

		document.getElementById('totaldiv').className="totaldiv_bg1";
		document.getElementById('addcontacts').className="addtask_bg2";
		document.getElementById('addcontacts').style.display="";
		document.getElementById('firstname').focus();
		hdnaddtype.value="add";

		firstname.value="";
		lastname.value="";
		contactcompany.value="";
		title.value="";
		representation.value="";
		contactemail.value="";
		website.value="";
		contactphone.value="";
		fax.value="";
		address1.value="";
		address2.value="";
		city.value="";
		state.value="";
		zip.value="";
		country.value="";
		contactnotes.value="";
	}
}
function fun_importcontacts()
{
	with(document.frm_contactlist)
	{
		browser = navigator.appName;
		ie = "Microsoft Internet Explorer";
		os = navigator.platform;
		if (browser == ie)
		{
			var boxHeight = document.getElementById("contactlistdiv").offsetHeight;
			var totheight=boxHeight+30;
		}
		else
		{
			var boxHeight = document.getElementById("contactlistdiv").clientHeight;
			var totheight=boxHeight+16;
		}
		document.getElementById('totaldiv').style.height=totheight;

		document.getElementById('totaldiv').className="totaldiv_bg1";
		document.getElementById('importcontacts').className="addtask_bg2";
		document.getElementById('importcontacts').style.display="";
	}
}
function canceladdprojectcontact()
{
	browser = navigator.appName;
	ie = "Microsoft Internet Explorer";
	os = navigator.platform;

	if (browser ==  ie)
	{
		for(var i=1;i<=document.getElementById('tot_guests').value;i++)
		{
			var guest_id = "rsvp"+i;
			document.getElementById(guest_id).style.display='';
		}

		for(var i=1;i<=document.getElementById('tot_press').value;i++)
		{
			var press_id= "rsvppress"+i;
			document.getElementById(press_id).style.display='';
		}
	}
    
	document.getElementById('addcontacts').style.display="none";
	document.getElementById('totaldiv').className="";
	document.getElementById('totaldiv').style.height="";
}
function canceladdcontact()
{
	document.getElementById('addcontacts').style.display="none";
	document.getElementById('totaldiv').className="";
	document.getElementById('totaldiv').style.height="";
	hdnsamplecsv.value="";
}
function cancelimportcontact()
{
	document.getElementById('importcontacts').style.display="none";
	document.getElementById('totaldiv').className="";
	document.getElementById('totaldiv').style.height="";
}
function fun_samplecsv_list()
{
	with(document.frm_contactlist)
	{
		hdnsamplecsv.value="downloadsample";
		submit();
	}
}

function MultipleSel2()
{
	with(document.frm_guestlist)
	{
		poststr="users="+document.getElementById("contactlistselect").value;
		var user=document.getElementById("contactlistselect");
		var r = "";
		for (var i=0; i<user.options.length; i++)
		{
			if (user.options[i].selected)
			{
				r = r+user.options[i].value+",";							
			}
		}
		var multiurl=r.substr(0,r.length-1);
		document.getElementById("hdnmultipleval").value=multiurl;
	}
}
function MultipleSel1()
{
	with(document.frm_adddguestspopup)
	{
		poststr="users="+document.getElementById("contactlistselect").value;
		
		var user=document.getElementById("contactlistselect");
		var r = "";
		for (var i=0; i<user.options.length; i++)
		{
			if (user.options[i].selected)
			{
				r = r+user.options[i].value+",";							
			}
		}
		var multiurl=r.substr(0,r.length-1);
		document.getElementById("contacts").value=multiurl;
	}
}
function fun_tasknotesdisp(to_do_id)
{
	with(document.frm_guestlist)
	{
		var project_id=hdnprojectid.value;
		windowName = "popuptasknotes";
		target = windowName;
		action="popuptasknotes.php?taskid="+to_do_id+"&project_id="+project_id;
		open('',windowName,'menubar=no,status=no,width=400,height=300,toolbar=no,left=250,top=250,scrollbars=no');
		submit(); 
		target="";
		action="";

	}
}
function fun_box_open()
{
	with(document.emailfriend)
	{
		var hidval=count_hid.value;
		hidval++;
		var	openid='link'+hidval;
		document.getElementById(openid).style.display='';
		if(hidval==10)
		{
		document.getElementById('addlink').style.display='none';
		}
		count_hid.value=hidval;		
		return false;
	}
}
function sendmail_friend()
{
with(document.emailfriend)
	{
		if((email_id_1.value!='') && (!validateEmail(email_id_1.value)))
		{
			alert('Please enter the valid Email Id1');
			email_id_1.focus();
			return false;
		}
		else if((email_id_2.value!='') && (!validateEmail(email_id_2.value)))
		{
			alert('Please enter the valid Email Id2');
			email_id_2.focus();
			return false;
		}
		else if((email_id_3.value!='') && (!validateEmail(email_id_3.value)))
		{
			alert('Please enter the valid Email Id3');
			email_id_3.focus();
			return false;
		}
		else if((email_id_4.value!='') && (!validateEmail(email_id_4.value)))
		{
			alert('Please enter the valid Email Id4');
			email_id_4.focus();
			return false;
		}
		else if((email_id_5.value!='') && (!validateEmail(email_id_5.value)))
		{
			alert('Please enter the valid Email Id5');
			email_id_5.focus();
			return false;
		}
		else if((email_id_6.value!='') && (!validateEmail(email_id_6.value)))
		{
			alert('Please enter the valid Email Id6');
			email_id_6.focus();
			return false;
		}
		else if((email_id_7.value!='') && (!validateEmail(email_id_7.value)))
		{
			alert('Please enter the valid Email Id7');
			email_id_7.focus();
			return false;
		}
		else if((email_id_8.value!='') && (!validateEmail(email_id_8.value)))
		{
			alert('Please enter the valid Email Id8');
			email_id_8.focus();
			return false;
		}
		else if((email_id_9.value!='') && (!validateEmail(email_id_9.value)))
		{
			alert('Please enter the valid Email Id9');
			email_id_9.focus();
			return false;
		}
		else if((email_id_10.value!='') && (!validateEmail(email_id_10.value)))
		{
			alert('Please enter the valid Email Id10');
			email_id_10.focus();
			return false;
		}
		else
		{
			hid_send.value="friend";
			submit();
		}
		
	}
}
function fun_searchcontacts()
{
	with(document.frmsearchcontacts)
	{
		var check_total = hdncontacttotal.value-1;
		var ischecked = false;
		for(var i=1;i<=check_total;i++)
		{
			check_control = "check"+i;
			if(document.getElementById(check_control).checked == true)
			{
				ischecked = true;
				break;
			}
		}
		if(ischecked == true)
		{
			hdnsearchadd.value="add";
			submit();
		}
		else
		{
			alert("Please select at least one contact");
			return false;
			check1.focus();
		}
	}
}
function fun_searchguests()
{
	with(document.frmsearchguests)
	{
		var check_total = hdncontacttotal.value-1;
		var ischecked = false;
		for(var i=1;i<=check_total;i++)
		{
			check_control = "check"+i;
			if(document.getElementById(check_control).checked == true)
			{
				ischecked = true;
				break;
			}
		}
		if(ischecked == true)
		{
			hdnsearchadd.value="add";
			submit();
		}
		else
		{
			alert("Please select at least one contact");
			return false;
			check1.focus();
		}
	}
}
function addtask(mode)
{
with(document.frm_addtask)
	{
		var valdue=document.getElementById("due").checked;
		if(trimAll(tasktitle.value)=='')
		{
		alert("Please enter title of the task.");
		tasktitle.focus();
		return false;
		}
		if(valdue=='1')
		{
			if(due_day.value=="")
			{
				alert("Please select the due date.");
				due_day.focus();
				return false;
			}
			if(due_month.value=="")
			{
				alert("Please select the due month.");
				due_month.focus();
				return false;
			}
			if(due_year.value=="")
			{
				alert("Please select the due year.");
				due_year.focus();
				return false;
			}
		}
		if(due_priority.value=="")
		{
			alert("Please select the priority of this task.");
			due_priority.focus();
			return false;
		}
		if(notes.value=="")
		{
			alert("Please enter the notes for this task.");
			notes.focus();
			return false;
		}
		else
		{
			hid_action_mode.value=mode;
			submit();
		}
	}
}
function fun_viewentireguests()
{
	with(document.frm_guestlist)
	{
		var project_id=hdnprojectid.value;
		windowName = "popupviewentireguests";
		target = windowName;
		action="popupviewentireguests.php?project_id="+project_id;
		open('',windowName,'menubar=no,status=no,width=1100,height=700,toolbar=no,left=0,top=0,scrollbars=yes');
		submit(); 
		target="";
	}
}

function fun_downloadrsvp()
{
	with(document.frm_guestlist)
	{
		action="tcl-guestlist.php";
		hdnmode.value="projects_guests";
		hdn_attent_count.value=document.getElementById("guest_count_id").innerHTML;
		hdnaddcontacts.value='no';
		submit();
	}
}
function fun_downloadrsvp1()
{
	with(document.frm_guestlist)
	{
		action="tcl-project-detail.php";
		hdnmode.value="projects_presslist";
		hdn_attent_count.value=document.getElementById("press_count_id").innerHTML;
		hdnaddcontacts.value='no';
		hdnsamplecsv.value="";
		hdnmailing.value='';
		submit();
	}
}

function fun_downloadmailing1()
{
	with(document.frm_guestlist)
	{
		if(confirm("Please check your list so that all fields are completed before printing mailing lables."))
		{
			action="tcl-project-detail.php";
			hdnmode.value="projects_presslist";
			hdnaddcontacts.value='no';
			hdnsamplecsv.value="";
			hdnmailing.value='yes';
			submit();
		}
	}
}
function fun_printmailing()
{
	with(document.frm_guestlist)
	{
		var project_id=hdnprojectid.value;
		windowName = "popupprintmailing";
		target = windowName;
		action="popupprintmailing.php?project_id="+project_id;
		open('',windowName,'menubar=no,status=no,width=1100,height=700,toolbar=no,left=50,top=50,scrollbars=yes');
		submit(); 
		target="";
	}
}
function fun_printmailing1()
{
	with(document.frm_guestlist)
	{
		var project_id=hdnprojectid.value;
		windowName = "popupprintmailingpress";
		target = windowName;
		action="popupprintmailpress.php?project_id="+project_id;
		open('',windowName,'menubar=no,status=no,width=1100,height=700,toolbar=no,left=50,top=50,scrollbars=yes');
		submit(); 
		target="";
	}
}
function validateprintmailing()
{
	with(document.frm_printmailing)
	{
		if(guestselect.value=='' && check.checked==false)
		{
			alert('Please select user');
			return false;
		}
		else if(trimAll(subject.value)=='')
		{
			alert('Please enter subject');
			subject.focus();
			subject.value="";
			return false;
		}
		else if(validateTinyMCEEditor(message))
		{
			alert('Please enter message');
			message.focus();
			message.value="";
			return false;
		}
		else
		{
			hdnmode.value="submit";
			submit();
		}
	}
}
function MultipleSel4()
{
	with(document.frm_printmailing)
	{
		poststr="users="+document.getElementById("guestselect").value;
		
		var user=document.getElementById("guestselect");
		var r = "";
		for (var i=0; i<user.options.length; i++)
		{
			if (user.options[i].selected)
			{
				r = r+user.options[i].value+",";							
			}
		}
		var multiurl=r.substr(0,r.length-1);
		document.getElementById("guests").value=multiurl;
	}
}
function validatersvpupdate()
{
	with(document.frm_rsvpupdate)
	{
		if(rsvp[0].checked==false && rsvp[1].checked==false && rsvp[2].checked==false)
		{
			alert("Please select a RSVP status");
		}
		else
		{
			hdnmode.value="rsvpupdate";
			submit();
		}
	}
}
function del_projcontacts()
{
	with(document.frm_viewcontacts)
	{
		var totrows=HiddenNumRows.value;
		var checked='false';
		var totchecked=0;
		for(var i=1;i<=totrows;i++)
		{
			var check="check"+i;
			if(document.getElementById(check).checked==true)
			{
				checked='true';
				totchecked++;
			}
		}
		if(checked=='false')
		{
			alert('Please select at least one contact');
			return false;
		}
		else
		{
			hdntotchecked.value=totchecked;
			if(totchecked==1)
			{
				if(confirm("Do you really want to delete this contact?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
			else
			{
				if(confirm("Do you really want to delete these contacts?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
		}
	}
}

function del_guestcontacts()
{
	with(document.frm_viewguests)
	{
		var totrows=HiddenNumRows.value;
		var checked='false';
		var totchecked=0;
		for(var i=1;i<=totrows;i++)
		{
			var check="check"+i;
			if(document.getElementById(check).checked==true)
			{
				checked='true';
				totchecked++;
			}
		}
		if(checked=='false')
		{
			alert('Please select at least one contact');
			return false;
		}
		else
		{
			hdntotchecked.value=totchecked;
			if(totchecked==1)
			{
				if(confirm("Do you really want to delete this contact?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
			else
			{
				if(confirm("Do you really want to delete these contacts?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
		}
	}
}

function del_presscontacts()
{
	with(document.frm_viewguests)
	{
		var totrows=HiddenNumRows.value;
		var checked='false';
		//alert(totrows);
		var totchecked=0;
		for(var i=1;i<=totrows;i++)
		{
			var check="check"+i;
			if(document.getElementById(check).checked==true)
			{
				checked='true';
				totchecked++;
			}
		}
		if(checked=='false')
		{
			alert('Please select at least one contact');
			return false;
		}
		else
		{
			hdntotchecked.value=totchecked;
			if(totchecked==1)
			{
				if(confirm("Do you really want to delete this contact?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
			else
			{
				if(confirm("Do you really want to delete these contacts?"))
				{
					hdnmode.value='delete';
					submit();
				}
			}
		}
	}
}

function Multiplelistselection()
{
	with(document.frmemail_send_option)
	{
		var user=document.getElementById("ddlList");
		var r = "";
		for (var i=0; i<user.options.length; i++)
		{
			if (user.options[i].selected)
			{
				r = r+user.options[i].value+",";							
			}
		}
		var multiurl=r.substr(0,r.length-1);
		document.getElementById("sel_list_contacts").value=multiurl;
	}
}

function email_sendoptions()
{
	formname="frmemail_send_option";
	with(document.forms[formname])	
	{
		for (var i=0; i < document.frmemail_send_option.where_to_send.length; i++)
		{
			if (document.frmemail_send_option.where_to_send[i].checked)
			{
				var where_to_sendvalue = document.frmemail_send_option.where_to_send[i].value;
			}
		}
		for (var i=0; i < document.frmemail_send_option.when_to_send.length; i++)
		{
			if (document.frmemail_send_option.when_to_send[i].checked)
			{
				var when_to_sendvalue = document.frmemail_send_option.when_to_send[i].value;
			}
		}
		if(ddlList.value=="")
		{
			alert("Please select any of the list for send email");
			ddlList.focus();
			return false;			
		}
		if(where_to_sendvalue=='0')
		{
			if(send_to_email.value=='')
			{
			alert("Where to Send Your Test Email");
			send_to_email.focus();
			return false;	
			}
			if(send_to_email.value!='')
			{
				var test_emails_tosend=send_to_email.value;
				var split_emails=test_emails_tosend.split(",");
				for(cut=0;cut<=split_emails.length-1;cut++)
				{
					if(!validateEmail(split_emails[cut]))
					{
					alert("Please correct this email id as valid one "+" '"+split_emails[cut]+"' ");
					send_to_email.focus();
					return false
					}
				}
			}
		}	       
		if(when_to_sendvalue=='1')
		{
			if(when_day.value=='')
			{
			alert("Please select the day");
			when_day.focus();
			return false;	
			}
			if(when_month.value=='')
			{
			alert("Please select the month");
			when_month.focus();
			return false;	
			}
			if(when_year.value=='')
			{
			alert("Please select the year");
			when_year.focus();
			return false;	
			}
			if(when_hour.value=='')
			{
			alert("Please select the hour");
			when_hour.focus();
			return false;	
			}
		}
		if(email_confirm.checked==false)
		{
			alert("Please check your confirmtion in order to proceed.");
			email_confirm.focus();
			return false;	
		}
		else
		{
			action="email-approval.php";
			hid_email_action.value="email_send_option";
			submit();
		}
	}
}
function Multipleprojectselection()
{
 with(document.frmemail_send_option)
 {
  var user=document.getElementById("projectlist");
  var r = "";
  for (var i=0; i<user.options.length; i++)
  {
   if (user.options[i].selected)
   {
    r = r+user.options[i].value+",";       
   }
  }
  var multiurl=r.substr(0,r.length-1);
  document.getElementById("sel_project_contacts").value=multiurl;
 }
}
function validateaddtotcontacts()
{
	with(document.frm_contactlist)
	{
		var nullcount=0;
		for(var i=1;i<=6;i++)
		{
			var textbox1	="newcon"+i+"1";
			var textbox2	="newcon"+i+"2";
			var textbox3	="newcon"+i+"3";
			var textbox4	="newcon"+i+"4";
			if(trimAll(document.getElementById(textbox1).value)=="" && trimAll(document.getElementById(textbox2).value)=="" && trimAll(document.getElementById(textbox3).value)=="" && trimAll(document.getElementById(textbox4).value)=="")
			{
				nullcount++;
				if(nullcount==6)
				{
					alert("Please enter the contact details");
					newcon11.focus();
					return false;
				}
			}
			else if((trimAll(document.getElementById(textbox1).value)!="" || trimAll(document.getElementById(textbox2).value)!="" || trimAll(document.getElementById(textbox3).value)!="" || trimAll(document.getElementById(textbox4).value)!="") && (trimAll(document.getElementById(textbox1).value)=="" || trimAll(document.getElementById(textbox2).value)=="" || trimAll(document.getElementById(textbox3).value)=="" || trimAll(document.getElementById(textbox4).value)==""))
			{
				alert("Please enter all the values in row"+i);
				return false;
			}
		}

		for(var j=1;j<=6;j++)
		{
			var emailid="newcon"+j+"4";
			if((document.getElementById(emailid).value!="") && !validateEmail(document.getElementById(emailid).value))
			{
				alert("Please enter a valid email address in row "+j);
				document.getElementById(emailid).focus();
				return false;
			}
		}

		var groupid=Hdngroupid.value;
		action="mycontactlisthome.php?groupid="+groupid+"&mode=view&addcontacts=yes";
		submit();
		target="";
	}
}
function validatefulldetails()
{
	with(document.frm_contactlist)
	{
		if(trimAll(firstname.value)=='')
		{
			alert('Please enter first name');
			firstname.focus();
			firstname.value="";
			return false;
		}
		else if(trimAll(lastname.value)=='')
		{
			alert('Please enter last name');
			lastname.focus();
			lastname.value="";
			return false;
		}
		else if(trimAll(contactcompany.value)=='')
		{
			alert('Please enter company name');
			contactcompany.focus();
			contactcompany.value="";
			return false;
		}
		else if(trimAll(contactemail.value)=='')
		{
			alert('Please enter email address');
			contactemail.focus();
			contactemail.value="";
			return false;
		}
		else if((contactemail.value!='') && (!validateEmail(contactemail.value)))
		{
			alert('Please enter a valid email address');
			contactemail.focus();
			return false;
		}
		else if(trimAll(contactphone.value)=='')
		{
			alert('Please enter phone number');
			contactphone.focus();
			contactphone.value="";
			return false;
		}
		else
		{
			var groupid=Hdngroupid.value;
			document.getElementById('addcontacts').style.display="none";
			document.getElementById('totaldiv').className="";
			document.getElementById('totaldiv').style.height="";
			action="mycontactlisthome.php?groupid="+groupid+"&mode=view&addfulldetails=yes";
			submit();
			target="";
		}
	}
}
function fun_samplecsv()
{
	with(document.frm_guestlist)
	{
		hdnsamplecsv.value="downloadsample";
		hdnaddcontacts.value="";
		action="tcl-project-detail.php";
		submit();
		target="";
	}
}

function funimportlistcontacts()
{
	with(document.frm_contactlist)
	{
		file=trimAll(csvfile.value);		
		var ary = file.split(".");
		var ext = ary[ary.length-1].toLowerCase();
		if(trimAll(document.getElementById('csvfile').value)=="")
		{
			alert("Please browse your CSV to import the contacts");			
			return false;
		}	
		else if((!((ext=="csv")||(ext=="CSV"))) && (csvfile.value!='')) 
		{
		alert("You have selected a '."+ ext +"' file, please Select the file of type '.csv'");				
		csvfile.focus();
		csvfile.value="";
		return false;
		}
		else
		{
			hdnsamplecsv.value="import";
			document.getElementById('importcontacts').style.display="none";
			document.getElementById('totaldiv').className="";
			var groupid=Hdngroupid.value;
			document.getElementById('totaldiv').style.height="";
			action="mycontactlisthome.php?groupid="+groupid+"&mode=view";
			submit();
			target="";
			return true;
		}
	}
}
function remove_emailmarket_selections(myid)
{
	with(document.ordersummary)
	{
		var totalemailmark=total_box.value;
		for( ids=1;ids<=totalemailmark-1;ids++ )
		{			
			if(ids!=myid)				
			document.getElementById("emailmonthcheck_"+ids).checked=false;			
		}
	}
}

function emailmarket_selections(myid)
{
	with(document.emailmarketing)
	{
		var totalemailmark=total_chk.value;
		for( ids=1;ids<=totalemailmark-1;ids++ )
		{			
			if(ids!=myid)				
			document.getElementById("emailmonth_"+ids).checked=false;			
		}
	}
}



function addmy_users()
{
with(document.company_users)
	{
		if(trimAll(first_name.value)=="")
		{
		alert("Please enter your first name");
		first_name.focus();
		return false;
		}		
		else if(trimAll(last_name.value)=="")
		{
		alert("Please enter your last name");
		last_name.focus();
		return false;
		}
		else if(trimAll(email.value)=="")
		{
		alert("Please enter your email address");
		email.focus();
		return false;
		}
		else if(!validateEmail(email.value))
		{
		alert("Please enter valid email address");
		email.focus();
		return false;
		}
		else if(trimAll(telephone.value)=="")
		{
		alert("Please enter your telephone number");
		telephone.focus();
		return false;
		}
		else if(trimAll(password.value)=="")
		{
		alert("Please enter your password");
		password.focus();
		return false;
		}
		else if(trimAll(password2.value)=="")
		{
		alert("Please enter your confirmation password");
		password2.focus();
		return false;
		}
		else if(password2.value!=password.value)
		{
		alert("Confirmation passwrod is mismatch with your password");
		password.focus();
		return false;
		}
		else if(trimAll(pass_hint.value)=="")
		{
		alert("Please enter your pasword hint");
		pass_hint.focus();
		return false;
		}		
		else if(trimAll(street_1.value)=="")
		{
		alert("Please enter your address");
		street_1.focus();
		return false;
		}
		else if(trimAll(city.value)=="")
		{
		alert("Please enter your city");
		city.focus();
		return false;
		}
		else if(trimAll(state.value)=="")
		{
		alert("Please enter your state");
		state.focus();
		return false;
		}
		else if(trimAll(postcode.value)=="")
		{
		alert("Please enter your postcode");
		postcode.focus();
		return false;
		}
		else if(trimAll(country_id.value)=="")
		{
		alert("Please select your country");
		country_id.focus();
		return false;
		}		
		else
		{
			hid_company_user.value="company";
			submit();
			return true;
		}
	}
}
function open_entry_form()
{
with(document.company_users)
	{
	document.getElementById('form_entry').style.display="";
	document.getElementById('message_box').style.display="none";
	return false;
	}
}

function compare_todayDate(value1) {
	var month1 = value1.substring (0, value1.indexOf ("-"));
	var date1 = value1.substring (value1.indexOf ("-")+1, value1.lastIndexOf ("-"));
	var year1 = value1.substring (value1.lastIndexOf ("-")+1, value1.length);

	var mname=getMonthName(month1);
	var todate = new Date();
	var entereddate=mname + " " + date1+ " " + year1+" 23:59:59 GMT+0530 (India Standard Time)";

	var entereddate = new Date(entereddate);
	if (entereddate < todate)
	{
	return false;
	}
	else
	return true;
}
function getMonthName(month)
{
if(month==1)
return "January";
else if(month==2)
return "February";
else if(month==3)
return "March";
else if(month==4)
return "April";
else if(month==5)
return "May";
else if(month==6)
return "June";
else if(month==7)
return "July";
else if(month==8)
return "August";
else if(month==9)
return "September";
else if(month==10)
return "October";
else if(month==11)
return "November";
else
return "December";
}
function fun_yearpack_validation(grupcunt,grpnum)
{
with(document.oneyearsubscribe)
	{		
		check_sel=false;
		for(i=1;i<=grupcunt;i++)
		{		
			if(document.getElementById("year_"+grpnum+i).checked==true)
			{
				check_sel=true;	
				break;
			}			
			if(document.getElementById("yearpack_"+grpnum+"1").checked==true)
			{
				check_sel=true;	
				break;
			}
			if(document.getElementById("month_"+grpnum+i).checked==true)
			{
				check_sel=true;
				break;
			}
			
		}	
				
		if(check_sel==false)
		{
			alert("Please select a list to subscribe");
			return false;
		}
		else
		{
			fulllist.value="year_lists_subscribe";
			submit();		
			return true;
		}		
	}

}

function fun_joinsub()
{
	with(document.form_subscribe)
	{
		if(trimAll(first_name.value)=="")
		{
			alert("Please enter your first name");
			first_name.focus();
			return false;
		}		
		else if(trimAll(last_name.value)=="")
		{
			alert("Please enter your last name");
			last_name.focus();
			return false;
		}
		else if(trimAll(email.value)=="")
		{
			alert("Please enter your email address");
			email.focus();
			return false;
		}
		else if(!validateEmail(email.value))
		{
			alert("Please enter valid email address");
			email.focus();
			return false;
		}
		else if(trimAll(telephone.value)=="")
		{
			alert("Please enter your telephone number");
			telephone.focus();
			return false;
		}
		else if(trimAll(password.value)=="")
		{
			alert("Please enter your password");
			password.focus();
			return false;
		}
		else if(trimAll(password2.value)=="")
		{
			alert("Please enter your confirmation password");
			password2.focus();
			return false;
		}
		else if(password2.value!=password.value)
		{
			alert("Confirmation passwrod is mismatch with your password");
			password.focus();
			return false;
		}
		else if(trimAll(pass_hint.value)=="")
		{
			alert("Please enter your pasword hint");
			pass_hint.focus();
			return false;
		}
		else if(trimAll(name.value)=="")
		{
			alert("Please enter the name of your card");
			name.focus();
			return false;
		}
		else if(trimAll(street_1.value)=="")
		{
			alert("Please enter your address");
			street_1.focus();
			return false;
		}
		else if(trimAll(city.value)=="")
		{
			alert("Please enter your city");
			city.focus();
			return false;
		}
		else if(trimAll(state.value)=="")
		{
			alert("Please enter your state");
			state.focus();
			return false;
		}
		else if(trimAll(postcode.value)=="")
		{
			alert("Please enter your postcode");
			postcode.focus();
			return false;
		}
		else if(trimAll(country_id.value)=="")
		{
			alert("Please select your country");
			country_id.focus();
			return false;
		}
		else if(trimAll(cc_num_trunc.value)=="")
		{
			alert("Please enter your credit card number");
			cc_num_trunc.focus();
			return false;
		}
		else if(trimAll(expiration_month.value)=="")
		{
			alert("Please select the expiration month");
			expiration_month.focus();
			return false;
		}
		else if(trimAll(expiration_year.value)=="")
		{
			alert("Please select the expiration year");
			expiration_year.focus();
			return false;
		}
		else if(trimAll(cvv.value)=="")
		{
			alert("Please enter the CVV");
			cvv.focus();
			return false;
		}
		else if(trimAll(wyk.value)=="")
		{
			alert("Where did you here about us?");
			wyk.focus();
			return false;
		}
		/*else if(termstcl.checked==false || termstfl.checked==false)
		{
			alert("You must agree to the terms in order to proceed!!");
			return false;
		}*/
		else
		{
			hid_sub_form.value="joinsubscribe";
			submit();
			return true;
		}
	}
}

function disp_contact_detail(contact_id,form_name,event_id,div_id)
{
	with(document.forms[form_name])
	{
		strPostRegData = "contact_id="+contact_id;
		url="ajax-disp-contact-detail.php";
		//Does URL begin with http?
		if(url.substring(0, 4) != 'http')
		{
			url = base_url + url;
		}
		if(window.XMLHttpRequest)
			http_req = new XMLHttpRequest();
		else if(window.ActiveXObject)
			http_req = new ActiveXObject("Microsoft.XMLHTTP");
		if(http_req)
		{
			http_req.onreadystatechange = function()
			{
				if(http_req.readyState== 4)
				{
					var strResponseTxt= trimAll(http_req.responseText);
					//alert(strResponseTxt);
          			mousecontent(strResponseTxt);
				}
			};
			http_req.open("POST", url, true);
			http_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http_req.send(strPostRegData);
		}
	}
}

function disp_per_contact_detail(contact_id,form_name,event_id,div_id)
{
	with(document.forms[form_name])
	{
		strPostRegData = "contact_id="+contact_id;
		url="ajax-disp-personal-detail.php";
		//Does URL begin with http?
		if(url.substring(0, 4) != 'http')
		{
			url = base_url + url;
		}
		if(window.XMLHttpRequest)
			http_req = new XMLHttpRequest();
		else if(window.ActiveXObject)
			http_req = new ActiveXObject("Microsoft.XMLHTTP");
		if(http_req)
		{
			http_req.onreadystatechange = function()
			{
				if(http_req.readyState== 4)
				{
					var strResponseTxt= trimAll(http_req.responseText);
					//alert(strResponseTxt);
					mousecontent(strResponseTxt);
				}
			};
			http_req.open("POST", url, true);
			http_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http_req.send(strPostRegData);
		}
	}
}

function disp_project_contact(contact_id,form_name)
{
	with(document.forms[form_name])
	{
		strPostRegData = "contact_id="+contact_id;
		url="ajax-disp-project-detail.php";
		//Does URL begin with http?
		if(url.substring(0, 4) != 'http')
		{
			url = base_url + url;
		}
		if(window.XMLHttpRequest)
			http_req = new XMLHttpRequest();
		else if(window.ActiveXObject)
			http_req = new ActiveXObject("Microsoft.XMLHTTP");
		if(http_req)
		{
			http_req.onreadystatechange = function()
			{
				if(http_req.readyState== 4)
				{
					var strResponseTxt= trimAll(http_req.responseText);
					document.getElementById('dispdetails').style.display="";
					document.getElementById('dispdetails').innerHTML=strResponseTxt;
				}
			};
			http_req.open("POST", url, true);
			http_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http_req.send(strPostRegData);
		}
	}
}



var thumbnailviewer={
enableTitle: false, //Should "title" attribute of link be used as description?
enableAnimation: true, //Enable fading animation?
definefooter: '<div class="footerbar">CLOSE X</div>', //Define HTML for footer interface
defineLoading: '<img src=""> <br>Loading Image...', //Define HTML for "loading" div

/////////////No need to edit beyond here/////////////////////////

scrollbarwidth: 16,
opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5',
targetlinks:[], //Array to hold links with rel="thumbnail"

createthumbBox:function(){
//write out HTML for Image Thumbnail Viewer plus loading div
document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
this.thumbBox=document.getElementById("thumbBox")
this.thumbImage=document.getElementById("thumbImage") //Reference div that holds the shown image
this.thumbLoading=document.getElementById("thumbLoading") //Reference "loading" div that will be shown while image is fetched
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
},


centerDiv:function(divobj){ //Centers a div element on the page
var ie=document.all && !window.opera
var dom=document.getElementById
var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
var objwidth=divobj.offsetWidth //width of div element
var objheight=divobj.offsetHeight //height of div element
var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
divobj.style.top=Math.floor(parseInt(topposition))+"px"
divobj.style.visibility="visible"
},

showthumbBox:function(){ //Show ThumbBox div
this.centerDiv(this.thumbBox)
if (this.enableAnimation){ //If fading animation enabled
this.currentopacity=0.1 //Starting opacity value
this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
}
},


loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already
this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image
if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description?
imageHTML+='<br />'+link.getAttribute("title")
this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown
this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden)
this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself
this.featureImage.onload=function(){ //When target image has completely loaded
thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div
thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world!
}
if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/
this.featureImage.src=link.getAttribute("href")
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over
}
},

setimgopacity:function(value){ //Sets the opacity of "thumbimage" div per the passed in value setting (0 to 1 and in between)
var targetobject=this.featureImage
if (targetobject.filters && targetobject.filters[0]){ //IE syntax
if (typeof targetobject.filters[0].opacity=="number") //IE6
targetobject.filters[0].opacity=value*100
else //IE 5.5
targetobject.style.filter="alpha(opacity="+value*100+")"
}
else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
targetobject.style.MozOpacity=value
else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
targetobject.style.opacity=value
else //Non of the above, stop opacity animation
this.stopanimation()
},

opacityanimation:function(){ //Gradually increase opacity function
this.setimgopacity(this.currentopacity)
this.currentopacity+=0.1
if (this.currentopacity>1)
this.stopanimation()
},

stopanimation:function(){
if (typeof this.opacitytimer!="undefined")
clearInterval(this.opacitytimer)
},


closeit:function(){ //Close "thumbbox" div function
this.stopanimation()
this.thumbBox.style.visibility="hidden"
this.thumbImage.innerHTML=""
this.thumbBox.style.left="-2000px"
this.thumbBox.style.top="-2000px"
},

cleanup:function(){ //Clean up routine on page unload
this.thumbLoading=null
if (this.featureImage) this.featureImage.onload=null
this.featureImage=null
this.thumbImage=null
for (var i=0; i<this.targetlinks.length; i++)
this.targetlinks[i].onclick=null
this.thumbBox=null
},

dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},

init:function(){ //Initialize thumbnail viewer script by scanning page and attaching appropriate function to links with rel="thumbnail"
if (!this.enableAnimation)
this.opacitystring=""
var pagelinks=document.getElementsByTagName("a")
	
for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP

if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ //Begin if statement
  pagelinks[i].onclick=function(){
	 
	thumbnailviewer.stopanimation() //Stop any currently running fade animation on "thumbbox" div before proceeding
	thumbnailviewer.loadimage(this) //Load image
	return false
 }
 this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
} //end if statement
} //END FOR LOOP
//Reposition "thumbbox" div when page is resized
this.dotask(window, function(){if (thumbnailviewer.thumbBox.style.visibility=="visible") thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize")


} //END init() function

}







function top_newsvalidation()
{
	with(document.frm_signin_newsletter)
	{
		if(trimAll(document.getElementById('news_email').value)=="")
		{
			alert("Please enter your email address");
			document.getElementById('news_email').focus();
			document.getElementById('news_email').value="";
			return false;
		}
		else if(!validateEmail(document.getElementById('news_email').value))
		{
			alert("Please enter valid email address");
			document.getElementById('news_email').focus();
			return false;
		}
		else
		{
			document.getElementById('hdn_sign_news').value="signinnews";
			submit();
		}
	}
}

function fun_deleteproject(pjt_id,formname)
{
   with(document.forms[formname])
	{
	  if(confirm("Are you sure you want to delete this project?"))
		{
		Hdn_delpjt.value=pjt_id;
		submit();
		}
	}

}