//ajax.js
var img = new Image();
img.src = "images/loading.gif";
var contentid;
var extracontent;
var tempajaxaction;
var tempaction;
var globalaction;
var globalajaxaction;
var globalparams;
function fnAjaxCaller(contentelementid, action, ajax_action, params, content, hide_contentid)
{
	/*alert("hi");
	alert (contentelementid);alert (action);alert (ajax_action);alert (params);alert (content);alert (hide_contentid);*/
	globalaction = action;
	globalajaxaction = ajax_action;
	globalparams = params;
	/*
	contentelementid = Element where response should be displayed //id_divsubindustry
	action = fuse
	params = &id=1&name=vikrant
	ajax_action = action is action function
	hide_contentid = a comma seperated string divid,divid2,divid3
	*/
	tempaction = action;
	tempajaxaction = ajax_action;
	var d = new Date();
	var time = d.getTime();
	contentid = contentelementid;
	extracontent = content;
	
	var hide_content=hide_contentid;
	
	
	if(hide_content != "")
	{
		var arrContet = hide_content.split(",");
		for(var intCtr = 0; intCtr < arrContet.length; intCtr++)
		{
			$(arrContet[intCtr]).innerHTML = "";
			$(arrContet[intCtr]).style.display = "none";
		}
	}
   
	//var url = 'index.php?action='+ action +'&mode=ajax&ajax_action='+ ajax_action + params +'&'+time ;
	
	var url = sitename + "/index.php?action=" + action +'&mode=ajax&ajax_action='+ ajax_action + params +'&'+time ;
	//alert (url);
	//return false;
	//var url = 'index.php?action='+ action +'&mode=ajax&ajax_action='+ ajax_action + params +'&'+time ;
	var myAjax = new Ajax.Request(url,
	{
		method:'get',
		onLoading: fnAjaxRequestInProgress,
		onSuccess: fnProcessAjaxResponse,
		onFailure: fnAjaxRequestError		
	});	
}

function fnProcessAjaxResponse(transport)
{
	 var response = transport.responseText;
	 //alert(response);
	 if(response == false || response == "") response = "Data not available..";
	 $(contentid).style.display = "";
	 $(contentid).innerHTML = extracontent + response;
	 
}

function fnAjaxRequestInProgress(contentelementid)
{
	$(contentid).style.display = "";
	if (globalajaxaction == "changestatus")
		$(contentid).innerHTML = "<img src='images/ajax-loader.gif' />";
	else
		$(contentid).innerHTML = "<img src='images/loading.gif' />";
	
}

function fnAjaxRequestError()
{
	$(contentid).style.display = "";
	$(contentid).innerHTML = "Error !!!!! ";
}


//mf_lightbox.js
/*
	Multifaceted Lightbox
	by Greg Neustaetter - http://www.gregphoto.net
	
	INSPIRED BY (AND CODE TAKEN FROM)
	==================================
	The Lightbox Effect without Lightbox
	PJ Hyett
	http://pjhyett.com/articles/2006/02/09/the-lightbox-effect-without-lightbox
	

	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensend under:
	Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
	
*/

var intTop = 0;
var intHeight = 0;
var Lightbox = {
	lightboxType : null,
	lightboxCurrentContentID : null,
	refreshAfterClose : 0,
	
	showBoxString : function(content, boxWidth, boxHeight){
		this.setLightboxDimensions(boxWidth, boxHeight);
		this.lightboxType = 'string';
		var contents = document.getElementById('boxContents');
		contents.innerHTML = content;
		this.showBox();
		return false;
	},


	showBoxImage : function(href) {
		this.lightboxType = 'image';
		var contents = document.getElementById('boxContents');
		var objImage = document.createElement("img");
		objImage.setAttribute('id','lightboxImage');
		contents.appendChild(objImage);
		imgPreload = new Image();
		imgPreload.onload=function(){
			objImage.src = href;
			Lightbox.showBox();
		}
		imgPreload.src = href;
		return false;
	},

	showBoxByID : function(id, boxWidth, boxHeight) {
		this.lightboxType = 'id';
		this.lightboxCurrentContentID = id;
		this.setLightboxDimensions(boxWidth, boxHeight);
		var element = document.getElementById(id);
		var contents = document.getElementById('boxContents');
		contents.appendChild(element);
		//Element.show(id);
		document.getElementById(id).style.display = 'block';
		
		this.showBox();
		return false;
	},

	showBoxByAJAX : function(href, boxWidth, boxHeight) {
		this.lightboxType = 'ajax';
		this.setLightboxDimensions(boxWidth, boxHeight);
		var contents = document.getElementById('boxContents');
		
		var myAjax = new Ajax.Updater(contents, href, {method: 'get'});
				
		
		this.showBox();
		return false;
	},
	
	setLightboxDimensions : function(width, height) {
		var windowSize = this.getPageDimensions();
		if(width) {
			if(width < windowSize[0]) {
				document.getElementById('box').style.width = width + 'px';
			} else {
				document.getElementById('box').style.width = (windowSize[0] - 50) + 'px';
			}
		}
		if(height) {
			if(height < windowSize[1]) {
				document.getElementById('box').style.height = height + 'px';
			} else {
				document.getElementById('box').style.height = (windowSize[1] - 50) + 'px';
			}
		}
	},


	showBox : function() {
		//Element.show('overlay');
		document.getElementById("overlay").style.display='block';
		this.center('box');
		return false;
	},
	
	
	hideBox : function(){
		if(this.refreshAfterClose==1)
		{
			window.location.reload( true );	
		}
		else
		{
			var contents = document.getElementById('boxContents');
			if(this.lightboxType == 'id') {
				var body = document.getElementsByTagName("body").item(0);
				
				//Element.hide(this.lightboxCurrentContentID);
				document.getElementById(this.lightboxCurrentContentID).style.display='none';
				body.appendChild(document.getElementById(this.lightboxCurrentContentID));
			}
			contents.innerHTML = '';
			document.getElementById('box').style.width = null;
			document.getElementById('box').style.height = null;
			//Element.hide('box');
			document.getElementById('box').style.display='none';
			//Element.hide('overlay');
			document.getElementById('overlay').style.display='none';
			return false;
		}
	},
	
	// taken from lightbox js, modified argument return order
	getPageDimensions : function(){
		var xScroll, yScroll;
	
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight) 
		return arrayPageSize;
	},
	
	center : function(element){
		try{
			element = document.getElementById(element);
		}catch(e){
			return;
		}
		var windowSize = this.getPageDimensions();
		var window_width  = windowSize[0];
		var window_height = windowSize[1];
		
		document.getElementById('overlay').style.height = windowSize[3] + 'px';
		
		element.style.position = 'absolute';
		element.style.zIndex   = 99;
	
		var scrollY = 0;
	
		if ( document.documentElement && document.documentElement.scrollTop ){
			scrollY = document.documentElement.scrollTop;
		}else if ( document.body && document.body.scrollTop ){
			scrollY = document.body.scrollTop;
		}else if ( window.pageYOffset ){
			scrollY = window.pageYOffset;
		}else if ( window.scrollY ){
			scrollY = window.scrollY;
		}
	
		var elementDimensions = this.getDimensionsLightBox(element);
		var setX = ( window_width  - elementDimensions.width  ) / 2;
		var setY = ( window_height - elementDimensions.height ) / 2 + scrollY;
	
		setX = ( setX < 0 ) ? 0 : setX;
		setY = ( setY < 0 ) ? 0 : setY;
	
		element.style.left = setX + "px";
		
		element.style.top  = setY + "px"; // comment this line and uncomment fnSetTop if u want top animation;
		
		element.style.overflow = 'hidden';
		//fnSetTop(element.id,setY); // VIKRANT CHANGE
		fnSetHeight(element.id,parseInt(element.style.height)); // VIKRANT CHANGE
		
		element.style.display=''
	},
	
	getDimensionsLightBox: function(element) {
	
   if (element.style.display != 'none')
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = '';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = 'none';
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  },

	
	
	init : function() {				  
		var lightboxtext = '<div id="overlay" style="display:none"></div>';
		lightboxtext += '<div id="box" style="display:none">';
		lightboxtext += '<img id="close" src="images/close.gif" onClick="Lightbox.hideBox()" alt="Close" title="Close this window" />';
		lightboxtext += '<div id="boxContents"></div>';
		lightboxtext += '</div>';
		var body = document.getElementsByTagName("body").item(0);
		new Insertion.Bottom(body, lightboxtext);
	}
}


function fnSetTop (id,top)
{
   if(intTop <= top)
	{
		intTop = intTop + 20;
		document.getElementById(id).style.top = intTop + "px";
		var fnTop = setTimeout("fnSetTop('"+id+"',"+top+")", 1);
	}
	else
	{
		intTop = 0;
		clearTimeout(fnTop);
	}		
}


function fnSetHeight(id,height)
{
	if(intHeight <= height)
	{
		intHeight = intHeight + 40;
		document.getElementById(id).style.height = intHeight + "px";
		var fnHeight = setTimeout("fnSetHeight('"+id+"',"+height+")", 1);
	}
	else
	{
		intHeight = 0;	
		document.getElementById(id).style.overflow = 'auto';
		clearTimeout(fnHeight);
	}
}


function init() {
			Lightbox.init();
		}
		
/*Event.observe(window, 'load', init, false); 
		function init() {
			Lightbox.init();
		}*/
		

//validation.js
/*
Author: Pathfinder Solutions, India
Desc: The Form validation script for any type of form
*/

	
	function fnEmailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	
	var validChars="\[^\\s" + specialChars + "\]"
	
	var quotedUser="(\"[^\"]*\")"
	
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	
	var atom=validChars + '+'
	
	var word="(" + atom + "|" + quotedUser + ")"
	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	 {
		 //alert("Email address seems incorrect (check @ and .'s)") // VIKRNT
	 	 return false
	 }
	var user=matchArray[1]
	var domain=matchArray[2]
	
	// See if "user" is valid
	if (user.match(userPat)==null) {
		// user is not valid
		//alert("The username doesn't seem to be valid.") // VIKRANT
		return false
	}
	
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
	   for (var i=1;i<=4;i++) {
		 if (IPArray[i]>255) {
			 //alert("Destination IP address is invalid!") // VIKRANT
	  return false
		 }
		}
		return true
	}
	
	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	 //alert("The domain name doesn't seem to be valid.") // VIKRANT
		return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
		domArr[domArr.length-1].length>4) {
	   // the address must end in a two letter or three letter word.
	   //alert("The address must end in a three-letter domain, or two letter country.") //VIKRANT
	   return false
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	   //alert(errStr) // VIKRANT
	   return false
	}
	// If we've got this far, everything's valid!
	return true;
	}
	
	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 strSeparator = strValue.substring(2,3) 
			
			var arrayDate = strValue.split(strSeparator); 
			//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}
			var intDay = parseInt(arrayDate[1],10); 
		
			//check if month value and day value agree
			alert("dada"+arrayLookup[arrayDate[0]]);
			if(arrayLookup[arrayDate[0]] != null)
			{
			  if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
				return true; //found in lookup table, good date
			}
		
			//check for February (bugfix 20050322)
			//bugfix  for parseInt kevin
			//bugfix  biss year  O.Jp Voutat
			var intMonth = parseInt(arrayDate[0],10);
			if (intMonth == 2)
			{ 
				var intYear = parseInt(arrayDate[2]);
				if (intDay > 0 && intDay < 29)
				{
					return true;
				}
				else if (intDay == 29)
				{
					if ((intYear % 4 == 0) && (intYear % 100 != 0) || (intYear % 400 == 0))
					{
						// year div by 4 and ((not div by 100) or div by 400) ->ok
						return true;
					}   
				}
			}
		}  
		return false; //any other values, bad date
	}
	function ValidateCurrency(str)
	{
		//alert(str);
		/*if (str <= 0)
			return false;*/
		return /^[$]?\d{0,10}(\.\d{0,2})?$/.test(str);
	}
	function fnValidatePhone(strPhoneNumber)
	{
		var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/
        var validPhone = objRegExp.test(strPhoneNumber);
        if (!validPhone)
        {
          return false;
        }
		return true;
	}
	
	function fnValidateString(string)
	{
		var strLen = string.length
		var iChars = "*!|,\":<>[]{}`\';()@&$#%_-";
		for (var i = 0; i < strLen; i++) 
		{
			if (iChars.indexOf(string.charAt(i)) != -1) 
			{
				return false;
			}
		}
		if (string != "")
		{
			var pattern =new RegExp(/\d/);
			if (pattern.test(string))
				return false;
		}
		return true;
	}
	
	function fnValidateSpecialChar(string)
	{
		var iChars = /[`_\-~!@#$%&,.:;<>{}()=\/\"\/\*\/\^\/\+\/\|\/\/]/
        var SpecialChar = iChars.test(string);
		if (SpecialChar) 
		{
			return false;
		}
		return true;
	}
	
	function fnValidatePhoneNo(phone)
	{
		strNumVal = ((/[0-9]/.test(phone)));
		strCharVal = ((/[a-zA-Z]/.test(phone)));
		strInvalideChar = ((/[`_~!@#$%&,.:;<>{}=\/\"\/\*\/\^\/\+\/\|\/\/]/.test(phone)));
		
		if( strCharVal == true || strInvalideChar == true)
		{
			return false;
		}
		if( strNumVal == true)
		{
			return true;
		}
		return false;
	}
	
	function trim(stringToTrim) 
	{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	
	function fnIsNumber(intNumber)
	{
		if(isNaN(intNumber) == true)	
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	//  End -->
	
	/*
	FUNCTION: fnValidateInput
	PARAMS: form, input type
	*/
	function fnValidateInputType(theElement, strType)
	{
		var theForm = theElement, z = 0;
		var intChkCount = 0;
		for(z=0; z<theForm.length;z++)
		{
			if(theForm[z].type == strType)
			{
				switch (strType)
				{
					case "radio": if (theForm[z].checked == true)
								  {
									  intChkCount = intChkCount+1;
								  }
								  break;

					case "checkbox":  if (theForm[z].checked == true)
									  {
										  intChkCount = intChkCount+1;
									  }
									  break;
				}
			}
		  }
		  return intChkCount;
	}
	/*
	FUNCTION: fnValidateInput
	PARAMS: form, input type
	*/
	function fnValidateGroupField(theForm, theElement, strType)
	{
		var z = 0;
		var intChkCount = 0;
		for(z=0; z<theForm.length;z++)
		{
			if(theForm[z].type == strType)
			{
				switch (strType)
				{
					case "radio": if (theForm[z].checked == true && theElement.name == theForm[z].name)
								  {
									  intChkCount = intChkCount+1;
								  }
								  break;

					case "checkbox":  if (theForm[z].checked == true && theElement.name == theForm[z].name)
									  {
										  intChkCount = intChkCount+1;
									  }
									  break;
				}
			}
		  }
		  return intChkCount;
	}

	
	
	var lightbox = 1;
	function fnValidateForm(obj)
	{
		var frm = obj;
		var len = frm.elements.length;
		var errormsg = "";
		
		var noserrors = 0
		if(lightbox == 1)
			var linebreak = "<br /><img src='images/error_small.jpg' alt='error' border='0'  /> ";
		else
			var linebreak = "\n";
			
		for(var i=0 ; i<len ; i++) 
		{		
			var eletype = frm.elements[i].type;
			if( (eletype.toLowerCase() != "submit") && (eletype.toLowerCase() != "hidden"))
			{
				if(frm.elements[i].alt != "");
				{
					var arrValue = new Array();
					
					try
					{
						var strValue = "";
						
						if(frm.elements[i].type == 'textarea')
						{
							strValue = frm.elements[i].title;
						}
						else
						{
							strValue = frm.elements[i].alt;
						}
						
						if(frm.elements[i].type == 'select-one')
						{
							strValue = frm.elements[i].title;
						}

						var eleValue =  trim(frm.elements[i].value);

						if(frm.elements[i].type == 'checkbox')
						{
							eleValue = frm.elements[i].checked;
						}
						
						if(frm.elements[i].type == 'radio')
						{
							eleValue = frm.elements[i].checked;
						}
						
						arrValue = strValue.split(/:/);
						var vallength = arrValue.length
						if(vallength > 0)
						{
							for(var j=0 ; j<vallength ; j++) 
							{
								//alert(arrValue[j]);
								var formula = trim(arrValue[j]);
								var arrFormula = formula.split("-");
								if(arrFormula[0] == "M") // MANDATORY FIELD VALIDATION
								{
									if(eleValue == "")
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
									if(eleValue == "Find Your Magazine")
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
								}	
								
								if(arrFormula[0] == "E") // EMAIL VALIDATION
								{
									if(eleValue != "")
									{
										if(!fnEmailCheck(eleValue))
										{
											errormsg = errormsg +  linebreak + arrFormula[1];
											noserrors++;
										}
									}
								}	
								
								if(arrFormula[0] == "CHAR") // EMAIL VALIDATION
								{
									if(eleValue != "")
									{
										if(!fnValidateString(eleValue))
										{
											errormsg = errormsg +  linebreak + arrFormula[1];
											noserrors++;
										}
									}
								}

								if(arrFormula[0] == "PH") // PHONE VALIDATION
								{
									if(eleValue != "")
									{
										if(!fnValidatePhoneNo(eleValue))
										{
											errormsg = errormsg +  linebreak + arrFormula[1];
											noserrors++;
										}
									}
								}

								if(arrFormula[0] == "SEL") // SELECT BOX VALIDATION
								{
									
									if(eleValue != "")
									{
										if(eleValue == "")
										{
											errormsg = errormsg +  linebreak + arrFormula[1];
											noserrors++;
										}
									}
								}	

								if(arrFormula[0] == "CHK") // CHECK BOX FIELD VALIDATION
								{
									if(eleValue == false)
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
								}	

								if(arrFormula[0] == "RDO") // CHECK BOX FIELD VALIDATION
								{
									if(eleValue == false)
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
								}	

								if(arrFormula[0] == "NUM") // MANDATORY FIELD VALIDATION
								{
									if(eleValue != "")
									{
										if(!fnIsNumber(eleValue))
										{
											errormsg = errormsg +  linebreak + arrFormula[1];	
											noserrors++;
										}
									}
								}	
								
								if(arrFormula[0] == "MIN") // MINIMUM LIMIT
								{
									if(eleValue != "")
									{
										var string = eleValue;
										var limit = string.length;
										if(limit < parseInt(arrFormula[1]))
										{
											errormsg = errormsg + linebreak + arrFormula[2];
											noserrors++;
										}
									}
								}
								
								if(arrFormula[0] == "MAX") // MAXIMUM LIMIT
								{
									var string = eleValue;
									var limit = string.length;
									if(limit > parseInt(arrFormula[1]))
									{
										errormsg = errormsg +  linebreak + arrFormula[2];	
										noserrors++;
									}
								}
								
								if(arrFormula[0] == "BET") // BETWEEN LIMIT
								{
									var string = eleValue;
									var limit = string.length;
									if(limit < parseInt(arrFormula[1]) && limit > parseInt(arrFormula[2]))
									{
										errormsg = errormsg +  linebreak + arrFormula[3];
										noserrors++;
									}
								}	
								
								if(arrFormula[0] == "COMP") // COMPARISION BETWEEN TWO FIELDS
								{
									var compvalue = trim(document.getElementById(arrFormula[2]).value)
									if(compvalue)
									{
										if(arrFormula[1] == "==")
										{
											if(eleValue != compvalue)
											{
												errormsg = errormsg +  linebreak + arrFormula[3];
												noserrors++;
											}
										}
										if(arrFormula[1] == "!=")
										{
											if(eleValue == compvalue)
											{
												errormsg = errormsg +  linebreak + arrFormula[3];
												noserrors++;
											}
										}
									}
								}//
								
								if(arrFormula[0] == "CMPVALUE") // DUPLICATE VALIDATION
								{
									if(arrFormula[1] != eleValue)
									{
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;
									}
								}
								if(arrFormula[0] == "MAXNUM") // DUPLICATE VALIDATION
								{										
									if(parseInt(eleValue,10) < arrFormula[1])
									{											
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;						
									}											
									
								}
								
								if(arrFormula[0] == "CURR") // DUPLICATE VALIDATION
								{									
									if (eleValue != "")
									{
										if(!ValidateCurrency(eleValue))
										{
											errormsg = errormsg +  linebreak + arrFormula[1];
											noserrors++;
										}
									}
								}
								
								if(arrFormula[0] == "DEPEND") //COMPAIR TWO FIELDS
								{
									if(eleValue == "" && document.getElementById(arrFormula[1]).value == "")
									{
										errormsg = errormsg;
									}
									if(eleValue != "" && document.getElementById(arrFormula[1]).value == "")
									{
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;
									}
									else if(eleValue == "" && document.getElementById(arrFormula[1]).value != "")
									{
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;
									}
								}
								
								if(arrFormula[0] == "COMPOR") //COMPAIR TWO FIELDS
								{
									if(document.getElementById(arrFormula[1]).value != "" && document.getElementById(arrFormula[2]).value != "")
									{
										errormsg = errormsg +  linebreak + arrFormula[3];
										noserrors++;
									}
									if(document.getElementById(arrFormula[1]).value == "" && document.getElementById(arrFormula[2]).value == "")
									{
										errormsg = errormsg +  linebreak + arrFormula[3];
										noserrors++;
									}
								}
								if(arrFormula[0] == "INPUTFIELD") //VALIDATE FIELD TYPE
								{
									if(fnValidateInputType(obj, arrFormula[1]) == 0)
									{
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;
									}
								}
								if(arrFormula[0] == "GROUPSEL") //VALIDATE FIELD TYPE
								{
									if(fnValidateGroupField(obj, frm.elements[i], arrFormula[1]) == 0)
									{
										errormsg = errormsg +  linebreak + arrFormula[2];
										noserrors++;
									}
								}
								if(arrFormula[0] == "SPECHAR") //VALIDATE FIELD TYPE
								{
									if(!fnValidateSpecialChar(eleValue))
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
								}
								if(arrFormula[0] == "URL") //VALIDATE FIELD TYPE
								{
									if(!fnValidateUrl(eleValue) && eleValue != "")
									{
										errormsg = errormsg +  linebreak + arrFormula[1];
										noserrors++;
									}
								}
							}//
						}
					}
					catch(e)
					{ 
						//
					}
				}	
			}					 
		}
		
		
		if(errormsg == "") 
		{
			return true;			
		}
		else 
		{
			if(lightbox == 1)	
			{
				fnLightBoxError(errormsg, noserrors);
			}
			else
			{
				alert(errormsg);	
			}
			return false;
		}
		
	}

function fnLightBoxError(errormsg, noserrors)
{
	var lightheight = 175;
	var forheight = 0;
	if(noserrors > 3)
	{
		forheight = (noserrors - 3);
		subheight = (25 * forheight);
		lightheight = lightheight + subheight;
	}
	var warning = "<div id='errormessage'><img src='images/warning_small.jpg' alt='warning' border='0'  /><br />";
	warning =  warning + errormsg;
	warning = warning + "<br /><br /><br /><center><input type='button' value='Ok' class='button' style='width:40px;' onclick='Lightbox.hideBox()' /></center></div>";
	Lightbox.showBoxString(warning,350,lightheight);
}


function fnValidateUrl(strUrl)
{
     
	 var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]/
     if (tomatch.test(strUrl))
     {
         return true;
     }
     else
     {
         return false; 
     }
}

//search.js

/**
 * Add System Message Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage systemmessage
 */

/**
 * fnSearch function
 * @param 
 * @return search value for fuse
 */
function fnSearch()
{
	
	var strSearchVal = document.getElementById('txtSearch').value;	
	var strAction = "";
		if(strSearchVal!='')
		{
		    
			strAction = sitename+'/'+"index.php?action=searchmagazine";
			  document.frmTopSearch.action = strAction;
		      document.frmTopSearch.submit();
			  return true;
					}
		else
		{
			alert ("Please enter text for search")
			return false;			
  
		}
}
	
function fnJobSearch()
{
	var strSearchVal = document.getElementById('id_keywords').value;
	
	var strAction = "";
	if (strSearchVal && strSearchVal != "Enter Keyword...")
	{
		if(strSearchVal.length==1)
		{
			alert(" Please enter text more than one character to search.");
			return false;			
		}
		document.frmJobSearch.action = sitename+'/'+"index.php?action=searchresult&sub_searchjobs=Jobsearch&txt_keywords="+strSearchVal;
		document.frmJobSearch.submit();
		return true;
	}
	else
	{
		alert ("Please enter text for search")
		return false;
	}
}

function replaceAll(text, strA, strB)
{
    while ( text.indexOf(strA) != -1)
    {
        text = text.replace(strA,strB);
    }
    return text;
}

function fnEventSearch()
{
	var strSearchVal = document.getElementById('id_eventkeywords').value;
	var strAction = "";
	if (strSearchVal && strSearchVal != "Enter Keyword...")
	{
		if(strSearchVal.length==1)
		{
			alert(" Please enter text more than one character to search.");
			return false;			
		}
		strSearchVal = replaceAll(strSearchVal," ","+");
		document.frmEventSearch.action = sitename+'/'+"index.php?action=listeventnew&txt_keywords="+strSearchVal;		
		document.frmEventSearch.submit();
		return true;
	}
	else
	{
		alert ("Please enter text for search")
		return false;
	}
}

function fnWRUWOPplSearch()
{
	
	var strSearchVal = document.getElementById('id_pplkeywords').value;	
		//var strUpdateSearchVal = document.getElementById('id_srchUpdates').value;
	var strAction = "";
	if(strSearchVal && strSearchVal != "Enter Keyword...") 
	{
		if(strSearchVal.length==1) 
		{
			alert(" Please enter text more than one character to search.");
			return false;			
		}
		document.frmUserSearch.action = sitename+'/'+"index.php?action=searchpeople&que="+strSearchVal;		
		document.frmUserSearch.submit();
		return true;		
		
	}
	else
	{
		alert ("Please enter text for search")
		return false;
	}
}

function fnWRUWOUpdateSearch()
{
	
	var strUpdateSearchVal = document.getElementById('id_srchUpdates').value;	
	var strAction = "";
	if (strUpdateSearchVal && strUpdateSearchVal != "Enter Keyword...")
	{
		if(strUpdateSearchVal.length==1) 
		{
			alert(" Please enter text more than one character to search.");
			return false;			
		}
		
			document.frmUserSearchUpdates.action = sitename+'/'+"index.php?action=showallwruwo&que="+strUpdateSearchVal;
			document.frmUserSearchUpdates.submit();
			return true;
	}
	else
	{
		alert ("Please enter text for search")
		return false;
	}
}


    function fnValidateNewsSearchRight()
	{
	    
		var strErrorMessage = "";
        if(document.getElementById('companyid').value=="")
		{
			strErrorMessage = " Please enter Company Name.";
			 
		}
		if(strErrorMessage=="")
		{
			return true;
		}
		else
		{	
		   alert(strErrorMessage);
		   return false;
		}
		
	 }

//login.js

/**
 * Add State Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage state
 */
 function fnValidatePublicURL (strURL)
 {
	var iChars = /[ ?'`\\~!@#$%&,.:;<>{}()=\/\"\/\*\/\^\/\+\/\|\/\/]/
	var SpecialChar = iChars.test(strURL);
	if (SpecialChar)
	{
		return false;
	}
	return true;
}

/**
 * fnValidateInput function
 * @param 
 * @return bool true or false
 */
	function fnValidateLoginInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtloginemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email Id. \n";
				//document.getElementById('id_txtloginemail').focus();
			}
			
			if(document.getElementById('id_txtloginpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				//document.getElementById('id_txtloginpassword').focus();
			}
			
			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
	
	function fnValidatePopLoginInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtPoploginemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email Id. \n";
				//document.getElementById('id_txtloginemail').focus();
			}
			else
			{
				//document.getElementById('id_txtloginemail').value = document.getElementById('id_txtPoploginemail').value;
			}
			
			if(document.getElementById('id_txtPoploginpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				//document.getElementById('id_txtloginpassword').focus();
			}
			else
			{
				//document.getElementById('id_txtloginpassword').value = document.getElementById('id_txtPoploginpassword').value;
			}
			
			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
	
	function fnValidateInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtfname').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter First Name. \n";
				//document.getElementById('id_txtfname').focus();
			}
						
			if(document.getElementById('id_txtlname').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Last Name. \n";
				//document.getElementById('id_txtlname').focus();
			}
					
			
			if ( document.getElementById('id_txtemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email Id. \n";
			}
			else
			{
				
				var emailStr = document.getElementById('id_txtemail').value;
				
				if(!fnEmailCheck (emailStr))
				{
					strErrorMessage = strErrorMessage + " Enter Valid Email Id. \n";
				}
			}
			
			if ( document.getElementById('id_txtpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				intIsPass = 1;
			}
			
			/*if ( document.getElementById('id_txtverifypassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Verify Password. \n";
				intIsVerifPass = 1;
			}*/
			
			var strPass = document.getElementById('id_txtpassword').value;
			/*var strVerifyPass = document.getElementById('id_txtverifypassword').value;
				if(strPass != strVerifyPass)
				{
					strErrorMessage = strErrorMessage + " Both Password Should be Same. \n";
				}*/
			var strPasslenght = strPass.length;
				//if(!(4 < strPasslenght > 10))
				if(strPasslenght > 10 || strPasslenght < 4)
				{
					strErrorMessage = strErrorMessage + " Password should be in between 4 - 10 digits. \n";
				}
			/*add by digambar to validate user public url */
			if(document.getElementById('id_txtprofileURL').value =="" || document.getElementById('id_txtprofileURL').value =="username")
			{
				strErrorMessage = strErrorMessage + " Enter Screen Name.\n";
				//document.getElementById('id_txtprofileURL').focus();
			}
			if(document.getElementById('id_txtprofileURL').value !="" && document.getElementById('id_txtprofileURL').value !="username")
			{
				var strPurl=document.getElementById('id_txtprofileURL').value;
				if (!fnValidatePublicURL(strPurl)) 
				{
				  	strErrorMessage= strErrorMessage+" Spaces, Sumbols and Punctuations are not allowed in Screen Name.\n";
			  	}				
			}
			/*****************************/

			
/*			if ( document.frmRegisterLogmeIn.chkIAgree.checked == false)
			{
				strErrorMessage = strErrorMessage + " Read User Agreement and Policy. \n";
			} */

			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
/**
 * fnCheckPublicURL function
 * @param public URL
 * @return 
 */	

		
	function fnCheckPublicURL()
	{
		var strErrorMessage = "";
		if ( document.getElementById('id_txtprofileURL').value == "" || document.getElementById('id_txtprofileURL').value == "username")
		{
			strErrorMessage = strErrorMessage + " Enter Screen Name. \n";
			intIsPass = 1;
		}
		if ((document.getElementById('id_txtprofileURL').value.length) > 30)
		{
			strErrorMessage = strErrorMessage + "Screen Name should not be more than 30 character. \n";
			intIsPass = 1;
		}
		var strURL = document.getElementById('id_txtprofileURL').value;
	  	if (!fnValidatePublicURL(strURL)) 
		{
		  	strErrorMessage="Spaces, Sumbols and Punctuations are not allowed in Screen Name.\n";
	  	}
		if(strErrorMessage != "")
		{
			alert(strErrorMessage);
			return false;
		}
		
	  	fnAjaxCaller('id_divURLCheckResponse','logmein','checkURL', '&url='+strURL, '', '');
	}
	
	/*function changePublicURL()
	{
		var purl =document.getElementById('id_txtprofileURL').value;
		//alert(purl);
		if(purl=='')
			document.getElementById('id_refreshpublicurl12').innerHTML ='username';
		else
			document.getElementById('id_refreshpublicurl12').innerHTML = purl;
	}*/
	
	
	boolFirstName = 0;
	boolLastName = 0;
	boolEmail = 0;
	boolPassword = 0;
	
	/*function fnLoginField(objField, intPChange)
	{
		strFieldValue = objField.value;
		switch(objField.accessKey)
		{
			case "LE?":
				objField.value = "";
				//objField.style.color = "black";
				objField.accessKey = "LE";
			break;
			case "LP?":
				//objField.style.color = "black";
				objField.value = "";
				objField.accessKey = "EP";
			break;
			case "SF?":
				boolFirstName = 1;
				objField.value = "";
				//objField.style.color = "black";
				objField.accessKey = "SF";
			break;
			case "SL?":
				boolLastName = 1;
				//objField.style.color = "black";
				objField.value = "";
				objField.accessKey = "SL";
			break;
			case "SE?":
				boolEmail = 1;
				objField.value = "";
				//objField.style.color = "black";
				objField.accessKey = "SE";
			break;
			case "SP?":
				boolPassword = 1;
				//objField.style.color = "black";
				objField.value = "";
				objField.accessKey = "SP";
			break;
		}
		
/*		if(intPChange == 1)
		{
			switch(objField.accessKey)
			{			
				case "LP?": objField.accessKey = "EP"; break;
				case "SP?": objField.accessKey = "SP"; boolPassword = 1; break; 
			}
			
		}  ** 
	}*/
	
	
	function fnLoginField(objField)
	{
		strFieldValue = objField.value;
		switch(objField.accessKey)
		{
			case "LE?":
				objField.value = "";
				objField.accessKey = "LE";
				strLoginEmail = "Email";
				document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
				document.getElementById('lbl_txtloginemail').style.display = "";
				document.getElementById('lbl_txtloginemail').style.color=  "#000000";
				document.getElementById('id_txtloginemail').style.color=  "#000000";
			break;
			case "LP?":
				objField.value = "";
				objField.accessKey = "LP";
				objField.className = "input";
				strLoginPassword = "Password";
				document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
				document.getElementById('lbl_txtloginpassword').style.display = "";
				document.getElementById('lbl_txtloginpassword').style.color=  "#000000";
				document.getElementById('id_txtloginpassword').style.color=  "#000000";
			break;
			case "SF?":
				boolFirstName = 1;
				objField.value = "";
				objField.accessKey = "SF";
				strSignupFirstName = "First Name";
				document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
				document.getElementById('lbl_txtfname').style.display = "";
				document.getElementById('lbl_txtfname').style.color=  "#000000";
				document.getElementById('id_txtfname').style.color=  "#000000";
			break;
			case "SL?":
				boolLastName = 1;
				objField.value = "";
				objField.accessKey = "SL";
				strSignupLastName = "Last Name";
				document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
				document.getElementById('lbl_txtlname').style.display = "";
				document.getElementById('lbl_txtlname').style.color=  "#000000";
				document.getElementById('id_txtlname').style.color=  "#000000";
			break;
			case "SE?":
				boolEmail = 1;
				objField.value = "";
				objField.accessKey = "SE";
				strSignupEmail = "Email";
				document.getElementById('lbl_txtemail').innerHTML = strSignupEmail;
				document.getElementById('lbl_txtemail').style.display = "";
				document.getElementById('lbl_txtemail').style.color=  "#000000";
				document.getElementById('id_txtemail').style.color=  "#000000";
			break;
			case "SP?":
				boolPassword = 1;
				objField.value = "";
				objField.className = "input";
				objField.accessKey = "SP";
				strSignupPassword = "Password";
				document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
				document.getElementById('lbl_txtpassword').style.display = "";
				document.getElementById('lbl_txtpassword').style.color=  "#000000";
				document.getElementById('id_txtpassword').style.color=  "#000000";
			break;
		}
		
	}
	
	
	function fnShowCapcha()
	{
		if(fnValidateFieldInput())
		{
			document.getElementById('registerfielddiv').style.display = "none";
			document.getElementById('registercapchadiv').style.display = "";
			
			document.getElementById("id_mainTable").style.height= "270px";
			document.getElementById("id_mainTable").style.width= "310px";
			
			
			document.getElementById("box").style.height= "340px";
			document.getElementById("box").style.width= "360px";
			
			//Lightbox.hideBox();
			document.getElementById("newlogin").style.display='none';
			document.getElementById("loginseperator").style.display='none';
			///Lightbox.showBoxByID("divRegisterLogin", 550,335);
			
			
		}
		return false;
	}


	function fnHideCapcha()
	{
		document.getElementById('registerfielddiv').style.display = "";
		document.getElementById('registercapchadiv').style.display = "none";
		
		document.getElementById("id_mainTable").style.height= "300px";
		document.getElementById("id_mainTable").style.width= "520px";
		
		document.getElementById("box").style.height= "340px";
		document.getElementById("box").style.width= "550px";
			
		
		//Lightbox.hideBox();
		document.getElementById("newlogin").style.display='block';
		document.getElementById("newlogin").width='50%';
		document.getElementById("loginseperator").style.display='block';
		
		//Lightbox.showBoxByID("divRegisterLogin", 550,335);
			
		return false
	}
	
	/*function fnValidateFieldInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtfname').value == "" || document.getElementById('id_txtfname').accessKey == "SF?")
			{
				strErrorMessage = strErrorMessage + " Enter First Name. \n";
			}
			else
			{
				if(boolFirstName == 0 && document.getElementById('id_txtfname').accessKey == "SF?")
				{
					strErrorMessage = strErrorMessage + " Enter First Name. \n";
				}
			}
			/*
			if(document.getElementById('id_txtfname').value == "" || boolFirstName == 0 || document.getElementById('id_txtfname').accessKey == "SF?")
			{
				strErrorMessage = strErrorMessage + " Enter First Name. \n";
			}**
			if(document.getElementById('id_txtlname').value == "" || document.getElementById('id_txtlname').accessKey == "SL?")
			{
				strErrorMessage = strErrorMessage + " Enter Last Name. \n";
				//document.getElementById('id_txtlname').focus();
			}
			else
			{
				if(boolLastName == 0 && document.getElementById('id_txtlname').accessKey == "SL?")
				{
					strErrorMessage = strErrorMessage + " Enter Last Name. \n";
				}
			}
			
			/*
			if(document.getElementById('id_txtlname').value == "" || boolLastName == 0 || document.getElementById('id_txtlname').accessKey == "SL?")
			{
				strErrorMessage = strErrorMessage + " Enter Last Name. \n";
				//document.getElementById('id_txtlname').focus();
			}
			** /
					
			
			if ( document.getElementById('id_txtemail').value == "" || document.getElementById('id_txtemail').accessKey == "SE?")
			{
				strErrorMessage = strErrorMessage + " Enter Email Id. \n";
			}
			else
			{
				if(boolEmail == 0 && document.getElementById('id_txtemail').accessKey == "SE?")
				{
					strErrorMessage = strErrorMessage + " Enter Email Id. \n";
				}
				else
				{
					var emailStr = document.getElementById('id_txtemail').value;
					
					if(!fnEmailCheck (emailStr))
					{
						strErrorMessage = strErrorMessage + " Enter Valid Email Id. \n";
					}
				}
			}
			
			if ( document.getElementById('id_txtpassword').value == "" || document.getElementById('id_txtpassword').accessKey == "SP?")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				intIsPass = 1;
			}
			else
			{
				if(boolPassword == 0 && document.getElementById('id_txtpassword').accessKey == "SP?")
				{
					strErrorMessage = strErrorMessage + " Enter Password. \n";
					intIsPass = 1;
				}
			}
			
			var strPass = document.getElementById('id_txtpassword').value;
			var strPasslenght = strPass.length;
				//if(!(4 < strPasslenght > 10))
				if(strPasslenght > 10 || strPasslenght < 4)
				{
					strErrorMessage = strErrorMessage + " Password should be in between 4 - 10 digits. \n";
				}

			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}*/
	
	
	
	
	function fnValidateFieldInput()
	{
		var strSignupFirstName = "";
		var strSignupLastName = "";
		var strSignupEmail = "";
		var strSignupPassword = "";
		var strErrorMessage = ""
 		var strFnameNumericVal = ""; 
			if(document.getElementById('id_txtfname').value == "" || document.getElementById('id_txtfname').accessKey == "SF?")
			{
				strSignupFirstName = "<font color='red'>Enter First Name.</font>";
			}
			
			else
			{
				if(boolFirstName == 0 && document.getElementById('id_txtfname').accessKey == "SF?")
				{
					strSignupFirstName = "<font color='red'>Enter First Name.</font>";
				}
			}
			
			
			if(strSignupFirstName != "")
			{
				
				document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
				document.getElementById('lbl_txtfname').style.display = "";
			}
			
			if(document.getElementById('id_txtlname').value == "" || document.getElementById('id_txtlname').accessKey == "SL?")
			{
				strSignupLastName = "<font color='red'>Enter Last Name.</font>";
				//document.getElementById('id_txtlname').focus();
			}
			else
			{
				if(boolLastName == 0 && document.getElementById('id_txtlname').accessKey == "SL?")
				{
					strSignupLastName = "<font color='red'>Enter Last Name.</font>";
				}
			}
			
			if(strSignupLastName != "")
			{
				document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
				document.getElementById('lbl_txtlname').style.display = "";
			}
			
			
			if ( document.getElementById('id_txtemail').value == "" || document.getElementById('id_txtemail').accessKey == "SE?")
			{
				strSignupEmail = "<font color='red'>Enter Email Id.</font>";
			}
			else
			{
				if(boolEmail == 0 && document.getElementById('id_txtemail').accessKey == "SE?")
				{
					strSignupEmail = "<font color='red'>Enter Email Id.</font>";
				}
				else
				{
					var emailStr = document.getElementById('id_txtemail').value;
					
					if(!fnEmailCheck (emailStr))
					{
						strSignupEmail = "<font color='red'>Enter Valid Email Id.</font>";
					}
				}
			}
			
			if(strSignupEmail != "")
			{
				document.getElementById('lbl_txtemail').innerHTML = strSignupEmail;
				document.getElementById('lbl_txtemail').style.display = "";
			}
			
			
			if ( document.getElementById('id_txtpassword').value == "" || document.getElementById('id_txtpassword').accessKey == "SP?")
			{
				strSignupPassword = "<font color='red'>Enter Password.</font>";
				intIsPass = 1;
			}
			else
			{
				if(boolPassword == 0 && document.getElementById('id_txtpassword').accessKey == "SP?")
				{
					strSignupPassword = "<font color='red'>Enter Password.</font>";
					intIsPass = 1;
				}
			}
			
			var strPass = document.getElementById('id_txtpassword').value;
			var strPasslenght = strPass.length;
				//if(!(4 < strPasslenght > 10))
				if(strPasslenght > 10 || strPasslenght < 4)
				{
					strSignupPassword = "<font color='red'>Password should be in between 4 - 10 digits.</font>";
				}

			if(strSignupPassword != "")
			{
				document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
				document.getElementById('lbl_txtpassword').style.display = "";
			}
			
			if(strSignupFirstName == "" && strSignupLastName == "" && strSignupEmail == "" && strSignupPassword == "")
			{
				return true;
			}
			return false;
	}
	/*function fnValidateLoginMeinInput()
	/*{
			
		var strErrorMessage = "";
			if ( document.getElementById('id_txtloginemail').value == "" || document.getElementById('id_txtloginemail').accessKey == "LE?")
			{
				strErrorMessage = strErrorMessage + " Enter Email Id. \n";
			}
			else
			{
				if(boolEmail == 0 && document.getElementById('id_txtloginemail').accessKey == "LE?")
				{
					strErrorMessage = strErrorMessage + " Enter Email Id. \n";
				}
				else
				{
					var emailStr = document.getElementById('id_txtloginemail').value;
					
					if(!fnEmailCheck (emailStr))
					{
						strErrorMessage = strErrorMessage + " Enter Valid Email Id. \n";
					}
				}
			}
			
			if ( document.getElementById('id_txtloginpassword').value == "" || document.getElementById('id_txtloginpassword').accessKey == "LP?")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				intIsPass = 1;
			}
			else
			{
				if(boolPassword == 0 && document.getElementById('id_txtloginpassword').accessKey == "LP?")
				{
					strErrorMessage = strErrorMessage + " Enter Password. \n";
					intIsPass = 1;
				}
			}
			
			var strPass = document.getElementById('id_txtloginpassword').value;
			var strPasslenght = strPass.length;
				//if(!(4 < strPasslenght > 10))
				if(strPasslenght > 10 || strPasslenght < 4)
				{
					strErrorMessage = strErrorMessage + " Password should be in between 4 - 10 digits. \n";
				}

			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}
	}*/
	
	boolFirstName = 0;
	boolLastName = 0;
	boolEmail = 0;
	boolPassword = 0;
	boolLoginEmail = 0;
	boolLoginPassword = 0;
	
	function fnOnBlurLoginField(objField)
	{
		strFieldValue = objField.value;
		if(objField.value == "")
		{
			switch(objField.accessKey)
			{
				case "LE":
					objField.value = "Email?";
					objField.accessKey = "LE?";
					boolLoginEmail = 0;
					strLoginEmail = "Email";
					document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
					document.getElementById('lbl_txtloginemail').style.display = "none";
					document.getElementById('lbl_txtloginemail').style.color=  "#686e75";
					document.getElementById('id_txtloginemail').style.color=  "#686e75";
				break;
				case "LP":
					objField.value = "Password?";
					objField.accessKey = "LP?";
					objField.className = "passwordbg";
					boolLoginPassword = 0;
					strLoginPassword = "Password";
					document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
					document.getElementById('lbl_txtloginpassword').style.display = "none";
					document.getElementById('lbl_txtloginpassword').style.color=  "#686e75";
					document.getElementById('id_txtloginpassword').style.color=  "#686e75";
				break;
				case "SF":
					objField.value = "First Name?";
					objField.accessKey = "SF?";
					boolFirstName = 0;
					strSignupFirstName = "First Name";
					document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
					document.getElementById('lbl_txtfname').style.display = "none";
					document.getElementById('lbl_txtfname').style.color=  "#686e75";
					document.getElementById('id_txtfname').style.color=  "#686e75";
				break;
				case "SL":
					objField.value = "Last Name?";
					objField.accessKey = "SL?";
					boolLastName = 0;
					strSignupLastName = "Last Name";
					document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
					document.getElementById('lbl_txtlname').style.display = "none";
					document.getElementById('lbl_txtlname').style.color=  "#686e75";
					document.getElementById('id_txtlname').style.color=  "#686e75";
				break;
				case "SE":
					objField.value = "Email?";
					objField.accessKey = "SE?";
					boolEmail = 0;
					strSignupPassword = "Email";
					document.getElementById('lbl_txtemail').innerHTML = strSignupPassword;
					document.getElementById('lbl_txtemail').style.display = "none";
					document.getElementById('lbl_txtemail').style.color=  "#686e75";
				document.getElementById('id_txtemail').style.color=  "#686e75";
				break;
				case "SP":
					objField.value = "Password?";
					objField.accessKey = "SP?";
					objField.className = "passwordbg";
					boolPassword = 0;
					strSignupPassword = "Password";
					document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
					document.getElementById('lbl_txtpassword').style.display = "none";
					document.getElementById('lbl_txtpassword').style.color=  "#686e75";
				document.getElementById('id_txtpassword').style.color=  "#686e75";
				break;
			}
		}
	}
	
	function fnValidateLoginMeinInput()
	{
		strLoginEmail = "";	
		strLoginPassword = "";
		if ( document.getElementById('id_txtloginemail').value == "" || document.getElementById('id_txtloginemail').accessKey == "LE?")
		{
			strLoginEmail = "<font color='red'>Enter Email Id.</font>";
		}
		else
		{
			if(boolLoginEmail == 0 && document.getElementById('id_txtloginemail').accessKey == "LE?")
			{
				strLoginEmail = "<font color='red'>Enter Email Id.</font>";
			}
			else
			{
				var emailStr = document.getElementById('id_txtloginemail').value;
				
				if(!fnEmailCheck (emailStr))
				{
					strLoginEmail = "<font color='red'>Enter Valid Email Id.</font>";
				}
			}
		}
			
		if(strLoginEmail != "")
		{
			document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
			document.getElementById('lbl_txtloginemail').style.display = "";
		}
			
		if ( document.getElementById('id_txtloginpassword').value == "" || document.getElementById('id_txtloginpassword').accessKey == "LP?")
		{
			strLoginPassword = "<font color='red'>Enter Password.</font>";
			intIsPass = 1;
		}
		else
		{
			if(boolPassword == 0 && document.getElementById('id_txtloginpassword').accessKey == "LP?")
			{
				strLoginPassword = "<font color='red'>Enter Password.</font>";
				intIsPass = 1;
			}
		}
			
			
		var strPass = document.getElementById('id_txtloginpassword').value;
		var strPasslenght = strPass.length;
		//if(!(4 < strPasslenght > 10))
		if(strPasslenght > 10 || strPasslenght < 4)
		{
			strLoginPassword = "<font color='red'>minimum 4 - 10 character long.</font>";
		}

		if(strLoginPassword != "")
		{
			document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
			document.getElementById('lbl_txtloginpassword').style.display = "";
		}

		if(strLoginPassword == "" && strLoginEmail == "")
		{
			return true;
		}
		return false;
	}
	
//commonfunctions.js

/**
* Hide HTML elements
*
* @param string of elements
* @return Hide passed HTML elements
*/

function fnHideShowObject(strHideElements, strShowElements)
{	
	
	if (strHideElements != "")
	{
		arrHideElements = strHideElements.split(' ');
		for (intI = 0; intI < arrHideElements.length; intI++)
		{
			if (document.getElementById(arrHideElements[intI]).style.display == "")
			{
				document.getElementById(arrHideElements[intI]).value = "";
				document.getElementById(arrHideElements[intI]).style.display = "none";
			}
			else
			{
				document.getElementById(arrHideElements[intI]).style.display = "";
			}
		}
	}
	
	if (strShowElements != "")
	{
		arrShowElements = strShowElements.split(' ');
		for (intI = 0; intI < arrShowElements.length; intI++)
		{
			if (document.getElementById(arrShowElements[intI]).style.display == "none")
			{
				document.getElementById(arrShowElements[intI]).style.display = "";
			}
			else
			{
				document.getElementById(arrShowElements[intI]).value = "";
				document.getElementById(arrShowElements[intI]).style.display = "none";
			}
		}
	}
}

function fnLoginPopup()
{
	strFormAction = sitename + "/login?goto=" + returnurl;
	strRegeAction = sitename + "/signup?goto=" + returnurl;
	
	if (Base64.decode(returnurl) != "action=home")
	{
		document.frmPopupLogin.action = strFormAction;
		document.getElementById("id_RegisterLink").href = strRegeAction;
	}
	
	Lightbox.showBoxByID('id_LoginBox',400,250);
}

function fnClearText(objControl)
{
	strSearchValue = objControl.value;
	if (strSearchValue == "")
	{
		objControl.value = "Example: Who's the sexiest reality TV star?";
	}
	else
	{
		arrSearchValue = strSearchValue.split(":");
		if (arrSearchValue[0] == "Example")
			objControl.value = "";
	}
}

function fnCheckUncheckAll(theElement)
{
	var theForm = theElement.form, z = 0;

	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
		{
		   theForm[z].checked = theElement.checked;
		}
	}
}

function fnSetCheckAll(theElement)
{
	if (fnCheckUncheck(theElement) == 1)
		document.getElementById("checkall").checked = true;
	else
		document.getElementById("checkall").checked = false;
}

function fnCheckUncheck(theElement)
{
	var theForm = theElement.form, z = 0, intElementCnt = 0, intCheckCnt = 0;

	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
		{
			intElementCnt = intElementCnt + 1;
			if (theForm[z].checked == true)
				intCheckCnt = intCheckCnt + 1;
		}
	}
	
	if (intCheckCnt == intElementCnt)
		return 1;
	else
		return 0;
}

//base.js

function populate_date(month, day, year) {
  ge('date_month').value = month;
  ge('date_day').value = day;
  ge('date_year').value = year;
}

function ge(elem) {
  return document.getElementById(elem);
}

/*
 * Simple Ajax call method.
 *
 * From http://en.wikipedia.org/wiki/XMLHttpRequest
 */
function ajax(url, vars, callbackFunction) {
  var request =  new XMLHttpRequest();
  request.open("POST", url, true);
  request.setRequestHeader("Content-Type",
                           "application/x-www-form-urlencoded");

  request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
      if (request.responseText) {
        callbackFunction(request.responseText);
      }
    }
  };
  request.send(vars);
}


function fnSetRedirect(redirect)
{
	return true;	
	ajax("/index.php?fburl=1&url="+redirect,"","fnNice")	

}

function fnNice()
{
	//alert("good");	
}

//fbaccount.js
var showPopularNetwork = function (){
	$('show_popular_network').className = "shareTabActive";
	$('show_popular_network').style.top = "-23px";
	//$('share_network'+aId).style.borderBottom = "1px solid #868686";
	$('show_new_network').className = "shareTabInactive";
	$('show_new_network').style.top = "-24px";
	$('show_active_network').className = "shareTabInactive";
	$('show_active_network').style.top = "-24px";

	$('widget_new_nn_div').style.display = "none";
	$('widget_popular_nn_div').style.display = "block";
}
var showNewNetwork = function (){
	$('show_new_network').className = "shareTabActive";
	$('show_new_network').style.top = "-23px";
	$('show_popular_network').className = "shareTabInactive";
	$('show_popular_network').style.top = "-24px";
	$('show_active_network').className = "shareTabInactive";
	$('show_active_network').style.top = "-24px";

	$('widget_new_nn_div').style.display = "block";
	$('widget_popular_nn_div').style.display = "none";

}
var showActiveNetwork = function (){
	$('show_active_network').className = "shareTabActive";
	$('show_active_network').style.top = "-23px";
	$('show_popular_network').className = "shareTabInactive";
	$('show_popular_network').style.top = "-24px";
	$('show_new_network').className = "shareTabInactive";
	$('show_new_network').style.top = "-24px";

	$('widget_new_nn_div').style.display = "none";
	$('widget_popular_nn_div').style.display = "block";
}

var displayUserDetailInHotlist = function (){
}
var hideUserDetailInHotlist = function (){
}

/**
 * Set default tab for feed
 * Modified to set the default tab message.- Sharief on 15/12/08
 */
 var setFeedDefaultTab = function (sType){
 	// show loading image
 	$('default_feed_text').innerHTML = '<img src="'+ S3_STATIC_ASSETS_PATH + '/images/loader.gif">';
	var postParameters = "default_tab="+sType;
	var ajaxRequestOptions = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: postParameters,
		// Handle successful response
		onSuccess: setFeedDefaultTabCallback,
		// Handle 404
		on404: setFeedDefaultTab404Callback,
		// Handle other errors
		onFailure: setFeedDefaultTabFailureCallback
	}
	new Ajax.Request('/set-feed-tab', ajaxRequestOptions);
}

/**
 * Set default tab for feed success callback
 */
var setFeedDefaultTabCallback = function (response){
	//eval the json object
	response_data = eval('(' + response.responseText + ')');
	// Google Analytics - code to track add news action
	tracAjaxFunctionalities('/set-feed-tab');
	if (response_data.ok == true) {
		// hide loading image and show success message
		$('default_feed_text').innerHTML = "Default tab";
	}
}
/**
 * Set default tab for feed failure callback function
 */
var setFeedDefaultTabFailureCallback = function (){
	alert("Error on page");
}
/**
 * Set default tab for feed 404 callback function
 */
var setFeedDefaultTab404Callback= function (){
	alert("Error page is not found");
}

/**
 * Function to render getting started template
 * @author Narciss Singh
 * Date 03/03/2009
 */
  var gettingStartedRenderSequence = function (){
  	var postParameters = " ";
	var ajaxRequestOptions = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: postParameters,
		// Handle successful response
		onSuccess: gettingStartedRenderSequenceCallback,
		// Handle 404
		on404: gettingStartedRenderSequence404Callback,
		// Handle other errors
		onFailure: gettingStartedRenderSequenceFailureCallback
	}
	new Ajax.Request('/getting-started-sequence', ajaxRequestOptions);
}

/**
 * Set default tab for feed success callback
 */
var gettingStartedRenderSequenceCallback = function (response){
	//eval the json object
	//response_data = eval('(' + + ')');
	//alert(response_data);
	// Google Analytics - code to track add news action
	//tracAjaxFunctionalities('/getting-started-sequence');
	$('gettingStartedStepInfo').innerHTML =  response.responseText;

}

var gettingStartedRenderSequence404Callback = function (){
	alert("Error on page");

}

var gettingStartedRenderSequenceFailureCallback= function (){
	alert("Error page is not found");
}

/**
 * Bala 04/03/09:
 * Get user facebook friends
 */
var getFbFriends = function (fbUserId, pg, eleId){
 	var postParameters = "fb_user_id="+fbUserId+"&pg="+pg;
	var ajaxRequestOptions = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: postParameters,
		// Handle successful response
		onSuccess:  function(response){getFbFriendsCallback(response, pg, eleId)},
		// Handle 404
		on404: getFbFriends404Callback,
		// Handle other errors
		onFailure: getFbFriendsFailureCallback
	}
	new Ajax.Request('/get-fb-friends', ajaxRequestOptions);
}
/**
 * Get user facebook friends success callback
 */
var getFbFriendsCallback = function (response, pg, eleId){
	if(pg == "invite"){
		//eval the json object
		response_data = eval('(' + response.responseText + ')');
		$(eleId).style.display = "none";
		if(response_data.error == 0){
			excludeFbIds = response_data.exclude_ids;
			showInviteDialog();
		}
	}else{
		$('inviteFbFriends_body').innerHTML = response.responseText;
		eval($('fbUserExcludeIds').innerHTML);
	}
	// Google Analytics - code to track add news action
	//tracAjaxFunctionalities('/get-fb-friends');
}
/**
 * Get user facebook friends failure callback function
 */
var getFbFriendsFailureCallback = function (){
	alert("Error on page");
}
/**
 * Get user facebook friends 404 callback function
 */
var getFbFriends404Callback= function (){
 	alert("Error page is not found");
}

var excludeFbIds = "";
// show facebook invite box
function showInviteDialog(){
	FB.IFrameUtil.CanvasUtilServer.run(true);
	var ele=document.createElement("div");
	ele.setAttribute("iframeWidth","630px");
	ele.setAttribute("iframeHeight","450px");
	var uiEle=new FB.UI.PopupDialog("Invite Friends",ele,false,false);
	uiEle.setContentWidth(630);
	uiEle.setContentHeight(450);
	uiEle.set_placement(FB.UI.PopupPlacement.center);
	ele.setAttribute("fbml","<fb:fbml>"+"<fb:request-form style=\"width:630px; height:450px;\" action=\""+document.location.href+"\"\tmethod=\"POST\" invite=\"false\" type=\"Magazine Price Comparison\" "+"content=\"Check out <a href='http://"+location.host+"'>Magazine Price Comparision</a>, an easy and fun way to compare the Magazine Price. <fb:req-choice url='http://"+location.host+"' label='Confirm' />\">"+"<fb:multi-friend-selector\tshowborder=\"false\" actiontext=\"Invite your friends to Magazine Price Comparision.\" exclude_ids=\""+excludeFbIds+"\" rows=\"3\" bypass=\"cancel\"\tshowborder=\"false\" />"+"</fb:request-form>"+"</fb:fbml>");	
	uiEle.show();
	FB_RequireFeatures(["XFBML"],function(){
		var ele2=new FB.XFBML.ServerFbml(ele);
		FB.XFBML.Host.addElement(ele2);
	});
}

/**
 * Bala 08/03/09:
 * Follow facebook friends
 */
var followFbFriends = function (action){
	var user_ids = [];
	if(action == "follow") {
		$('followFbUsersLoader').style.display = "block";
		var objs = document.getElementsByName("follow_fb_friends");
		for(i=0;i<objs.length;i++) {
			if(objs[i].checked){
				user_ids.push(objs[i].value);
			}
		}
	}
	if(action == "follow" && user_ids.length == 0){
		$('followFbUsersLoader').style.display = "none";
		alert("Not selected any friends!");
		return false;
	}
 	var postParameters = "act="+action+"&follow_fb_friends="+user_ids.join(",");
	var ajaxRequestOptions = {
		// Use POST
		method: 'post',
		// Send this lovely data
		postBody: postParameters,
		// Handle successful response
		onSuccess:  function(response) {followFbFriendsCallback(response, action)},
		// Handle 404
		on404: followFbFriends404Callback,
		// Handle other errors
		onFailure: followFbFriendsFailureCallback
	}
	new Ajax.Request('/follow-fb-friends', ajaxRequestOptions);
}
/**
 * Follow facebook friends success callback
 */
var followFbFriendsCallback = function (response, action){
	// eval the json object
	response_data = eval('(' +response.responseText+ ')');
	// Google Analytics - code to track add news action
	tracAjaxFunctionalities('/follow-fb-friends');
	try {
		$('followFbUsersLoader').style.display = "none";
	} catch(e){}
	// hide getting started div
	if(response_data.message == "success") {
		if(action == "invite") {
			showInviteDialog();
			$('gettingStartedStepInfo').style.display = "none";
		}else if(response_data.refresh_url == "" || action == "close") {
			$('gettingStartedStepInfo').style.display = "none";
		} else {
			window.location = "http://"+location.host+response_data.refresh_url;
		}
	}
}
/**
 * Follow facebook friends failure callback function
 */
var followFbFriendsFailureCallback = function (){
	try {
		$('followFbUsersLoader').style.display = "none";
	} catch(e){}
	alert("Error on page");
}
/**
 * Follow facebook friends 404 callback function
 */
var followFbFriends404Callback= function (){
 	try {
		$('followFbUsersLoader').style.display = "none";
	} catch(e){}
 	alert("Error page is not found");
}


function fnHideShowText(objTextObject, strTempText)
{
	if (objTextObject.value == strTempText)
		objTextObject.value = "";
	else if (objTextObject.value == "")
		objTextObject.value = strTempText;
}

		
		