// JavaScript Document

getBrowserInfo();




function checkEnter(e){ 
	var characterCode 
	
	if(e && e.which){ // (NN4)
	e = e
	characterCode = e.which // NN4's which property
	}
	else{
	e = event
	characterCode = e.keyCode //IE's keyCode property
	}

	if(characterCode == 13){ //character code is equal to ascii 13 (if enter key)
		//document.forms[0].submit() //submit the form
		//return false
		printoMaster.validateForm('loginForm','Lemail##email,Lpassword##text','../myAccount/validate_user.asp','validate','loginMessage');
	}
	else{
		//return true
	}

}

	/************Object Opacity Control*/
function changeOpac (opacity, id) { 
		var object = $(id).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
		object="";
}


/*****Triming space of Given text*****/
function Trim(s) 
   {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
	 { s = s.substring(1,s.length); }
	 
	// Remove trailing spaces and carriage returns
 while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
	 { s = s.substring(0,s.length-1); }
	 
	 
	return s;
   }
/**********/



function printoMasterClass(){
	
		var ResponsWritePlace;
		var LoadedContent;
		var loaderDIVObjVar

		this.CreateAJAXRequest=function(url,rPlace,pars,lContent,loaderDIVObj){
		
		ResponsWritePlace=rPlace;
		LoadedContent=lContent;
		pars=pars+"&killCache="+new Date().getTime();
		ajaxURL=url;
		loaderDIVObjVar=""
		
		
		if(loaderDIVObj!=undefined){
			Element.show(loaderDIVObj);
			loaderDIVObjVar=loaderDIVObj;
		}
		else{
			if($('loadingDIV')){
				Element.show("loadingDIV")
			}
			
			///new style
			if($('loaderIndicator')){
				Element.show("loaderIndicator")
			}
		}
		

		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars, 
				onSuccess: CallSucess,
				onFailure:CallError,
				onComplete: showResponse
			}
		);
	}
	
	function CallSucess(){
		//Effect.Fade(ResponsWritePlace)
		//Effect.Opacity(LoadedContent, { from: 1.0, to: 0.5, duration: 0.5 });
	}
		
	function CallError(){
		alert('Your Request Failed \n --------  '+ajaxURL);
	}
	
///lightbox hiding 
	this.hideLightBoxOuterControl=function(){
		if(browser=="Internet Explorer"){
			commonUseLightBox1= new lightbox(); //for hideSelects function
			commonUseLightBox1.hideSelects('visible');
			commonUseLightBox1.setScroll(0,getCurrentScrollY);
			commonUseLightBox1.prepareIE('auto', 'hidden','auto');
		}
			
			if($('lbContent')){
				Element.remove($('lbContent'));
			}
			Element.hide($('overlay'));
			Element.hide($('lightbox'));
	}
	
	this.ShowLightBoxOuterControl=function(){
		if(browser=="Internet Explorer"){
			commonUseLightBox1= new lightbox(); //for hideSelects function
			commonUseLightBox1.hideSelects('hidden');
			commonUseLightBox1.getScroll();
			commonUseLightBox1.prepareIE('100%', 'hidden','hidden');
			commonUseLightBox1.setScroll(0,0);
		}
			
			Element.show($('overlay'));
			Element.show($('lightbox'));
	}
	
	this.ChangeLBPosSize=function(type){
		
			if(type==1){
				$('lightbox').style.width='700px'
				$('lightbox').style.height='500px'
				$('lightbox').style.left='40%'
				$('lightbox').style.top='40%'
	
				}
			else if(type==2){
				$('lightbox').style.width='600px'
				$('lightbox').style.height='330px'
				$('lightbox').style.left='45%'
				$('lightbox').style.top='45%'
				}
			else if(type==3){
				$('lightbox').style.width='400px'
				$('lightbox').style.height='300px'
				$('lightbox').style.left='55%'
				$('lightbox').style.top='60%'
				}
				
			else if(type==4){
				$('lightbox').style.width='835px'
				$('lightbox').style.height='500px'
				$('lightbox').style.left='40%'
				$('lightbox').style.top='40%'
				}
		
		}
		
	function showResponse(originalRequest){
		
		//this checking it is normal MASTER PAGES Request or lightbox submition? 
		//First one is normal MASTER PAGES AJAX Request
		///remove already available(prevoius loaded) element
		if(ResponsWritePlace!="noPrintRequired" || LoadedContent!="NoContent"){
			///remove already available(prevoius loaded) element
			if($(LoadedContent)){Element.remove($(LoadedContent));}
							

				//put returned XML in the Container
				info = "<div class='clearFloat' id="+LoadedContent+" style='overflow:auto;'>" + originalRequest.responseText + "</div>";
				
				new Insertion.Before($(ResponsWritePlace), info);//this enable javascript in loaded page
				
				Effect.Appear(LoadedContent);
				
				if(LoadedContent=="lbContent"){//problem for FireFox 
					$('lightbox').className = "done";
				}

				
				if(loaderDIVObjVar!=""){
					if($(loaderDIVObjVar)){
						Element.hide(loaderDIVObjVar)
						loaderDIVObjVar="";
					}
				}
				else{
					if($('loadingDIV')){
						Element.hide("loadingDIV")
					}
					
					///new style
					if($('loaderIndicator')){
						Element.hide("loaderIndicator")
					}
				}


		}//if end
		//Lightbox control after request over
		else{
				if(loaderDIVObjVar!=""){
					if($(loaderDIVObjVar)){
						Element.hide(loaderDIVObjVar)
						loaderDIVObjVar="";
					}
				}
				else{
					if($('loadingDIV')){
						Element.hide("loadingDIV")
					}
					
					///new style
					if($('loaderIndicator')){
						Element.hide("loaderIndicator")
					}
				}
			


				
				//$('responseText').value=originalRequest.responseText;
				//alert(originalRequest.responseText);
				//return false;
				//for avoiding responsetext's string conversion pblm that I stored into hidden TEXT Box
				
				
				var cutResponse= new Array();

				if($('responseText')){//if obj available
					$('responseText').value=originalRequest.responseText;
					cutResponse=$('responseText').value.split('+++');
					$('responseText').value=cutResponse[0];
				}
				

				///---------------------Registration--------------------------------------
				if(cutResponse[0]=="userDuplication"){//email or project duplication error for client,team
					Form.enable('registrationForm');
					$(cutResponse[1]).focus();
					$(cutResponse[1]).className='redBorder';
					
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[2]+' </span>'
				
				}
				else if(cutResponse[0]=="RegistrationSucess"){
					commonUseLightBox1= new lightbox(); //for hideSelects function
					commonUseLightBox1.hideSelects('hidden');

					Form.disable('registrationForm');	
					Element.show('displayAfterActionDIV')
					Element.show('displayAfterActionWriterDIV')
					$('displayAfterActionWriterDIV').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span><br><br><span class="floatLeft">Redirecting now... OR &nbsp;&nbsp;&nbsp; </span><a class="btnClass btnOranjL" href="javascript:;" onclick="location.href=&quot;'+cutResponse[3]+'&quot;" ><span class="btnOranjR">&nbsp;Start Here&nbsp;</span></a>'
					timeoutID = setTimeout("location.href='"+cutResponse[3]+"'", 6000);
				}
				
				///---------------------Login--------------------------------------
				else if(cutResponse[0]=="invalidUserName"){
					$(cutResponse[1]).focus();
					$(cutResponse[1]).className='redBorder';
					$(cutResponse[3]).className='redBorder';
					$('loginMessage').style.display="block";
					$('loginMessageWriterTd').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[2]+' </span>'
				}
				else if(cutResponse[0]=="loginSucess"){
					//alert("Specify redirect URL");
					//$(cutResponse[1]).style.display="none";
					//alert(true)
					location.href=cutResponse[2];
				}
				
				///---------------------Edit Profle--------------------------------------
				else if(cutResponse[0]=="profileUpdated"){		
				
					commonUseLightBox1= new lightbox(); //for hideSelects function
					commonUseLightBox1.hideSelects('hidden');

					Form.disable('registrationForm');
					Element.show('displayAfterActionDIV');
					Element.show('displayAfterActionWriterDIV');
					$('displayAfterActionWriterDIV').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span><br><br><a class="btnClass btnOranjL" href="javascript:;" onclick=location.href="'+cutResponse[3]+'" ><span class="btnOranjR">&nbsp;Close&nbsp;</span></a>'
					window.setTimeout(function (a,b) {location.href=cutResponse[3]},2000);
					//window.setTimeout(function (a,b) {alert(true)},1000,someString,someObject);
				}
			
			///---------------------Change Password--------------------------------------
			else if(cutResponse[0]=="passwordNotMatched"){
				
					Form.enable('registrationForm');

					$(cutResponse[1]).focus();
					$(cutResponse[1]).className='redBorder';
					
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[2]+' </span>'	
			}
			else if(cutResponse[0]=="passwordChanged"){
					commonUseLightBox1= new lightbox(); //for hideSelects function
					commonUseLightBox1.hideSelects('hidden');
					
					Form.disable('registrationForm');
					Element.show('displayAfterActionDIV');
					Element.show('displayAfterActionWriterDIV');
					$('displayAfterActionWriterDIV').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span><br><br><a class="btnClass btnOranjL" href="javascript:;" onclick=location.href="'+cutResponse[3]+'" ><span class="btnOranjR">&nbsp;Close&nbsp;</span></a>'
					window.setTimeout(function (a,b) {location.href=cutResponse[3]},2500);
				}
				
			///---------------------forgot Password--------------------------------------
			else if(cutResponse[0]=="InvalidEmail"){
					$(cutResponse[1]).focus();
					$(cutResponse[1]).className='redBorder';
					
					//$('fPErrorMessage').style.display="block";
					Effect.Appear('fPErrorMessage')
					$('fPErrorMessageWriter').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[2]+' </span>'	
			}// invalid email id === forgot password
			else if(cutResponse[0]=="emailSent"){
					//$('afterPasswordSentDiv').style.display="block";
					Element.show('afterPasswordSentDiv');Element.show('afterPasswordSentWriter');
					
					$('afterPasswordSentWriter').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'
					window.setTimeout(function (a,b) {Element.hide('afterPasswordSentDiv');$('forgotPasswordEmail').value="";Element.hide('afterPasswordSentWriter');$('forgotPassLink').onclick();},3000);
			}//forgot password
			
			//----------------------------------Admin---------------------------------------------
			else if(cutResponse[0]=="userAction"){
					//$('userActionMessage').style.display="block";
					Effect.Appear('userActionMessage')
					$('userActionMessage').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'
					
					if($('contentLoader')){
						printoMaster.CreateAJAXRequest('listUsers.asp','contentLoader','pge='+cutResponse[3]+'&view='+cutResponse[4]+'&querytext='+cutResponse[5],'contentLoaderTemp');
					}
					//timerCapt=window.setTimeout(function (a,b) {clearTimeout(timerCapt);Effect.Fade('userActionMessage');},2500);
					
					if($('loadingDIV')){
						Element.hide("loadingDIV")
					}
			}// use action
			//---------------------------------Refer a friend-----------------------------------------
			else if(cutResponse[0]=="afterReferSend"){
				$('referFriendForm').reset();
				Form.enable('referFriendForm');
				//$('messageBox').style.display="block";
				Effect.Appear("referMessageBox");
				$('referMessageWriterTD').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'				
			}//after send

			//---------------------------------feedback sent
			else if(cutResponse[0]=="afterMailSent"){
				Form.enable('mailForm');
				$('mailForm').reset();
				if($('otherGets')){
					$('otherGets').style.display="none";
				}
				if($('ifOtherProd')){
					$('ifOtherProd').disabled=true
				}
				Effect.Appear("messageBoxB");
				$('messageBoxBWriterTD').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'				
			}//after send
			//---------------------------------after community join mail sent
			else if(cutResponse[0]=="communitysent"){
				$('communityForm').reset();
				Form.enable('communityForm');
				//$('messageBox').style.display="block";
				Effect.Appear("referMessageBox");
				$('referMessageWriterTD').innerHTML='<span> <img src="../assets/images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'				
			}//after send
			
			
			//---------------------------------after news Updates
			else if(cutResponse[0]=="newsUpdated"){
				window.setTimeout(function (a,b) {location.href=cutResponse[3]+"?showM=1&message="+cutResponse[2]+"&adminNowAt=contentM&atContent=news"},100);			
			}//after news updates
			
			else if(cutResponse[0]=="newsAction"){
					//$('userActionMessage').style.display="block";
					Effect.Appear('userActionMessage')
					$('userActionMessage').innerHTML='<span> <img src="../images/icons/accept.gif" width="16" height="16" align="absmiddle"  /> <b>'+cutResponse[2]+'</b> </span>'
					
					if($('contentLoader')){
						printoMaster.CreateAJAXRequest('newsList.asp','contentLoader','pge='+cutResponse[3]+'&view=all&querytext='+cutResponse[5],'contentLoaderTemp');
					}
			}
			////Printo Career CITY creation
			
			else if(cutResponse[0]=="errorInFill"){ //duplication error, blank field errors (ex: ifOthers)
					Form.enable(cutResponse[1]);
					$(cutResponse[2]).focus();
					$(cutResponse[2]).className='redBorder';
					
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span> <img src="../images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[3]+' </span>'
	
			}
			else if(cutResponse[0]=="cityUpdated"){
				printoMaster.ChangeLBPosSize(1);
				printoMaster.ShowLightBoxOuterControl();
				printoMaster.CreateAJAXRequest("city_manager.asp","lbLoadMessage","showMess=1&Message="+cutResponse[2],"lbContent");
			}
			
			///securi
			else if(cutResponse[0]=="WrongSecurityCode"){
				Effect.Appear("messageBoxB");
				$('messageBoxBWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> '+cutResponse[3]+' </span>'
				Form.enable(cutResponse[1]);
				$(cutResponse[2]).focus();
				$(cutResponse[2]).className='redBorder';
				
				
			}
			
		}//else content
	}
	

		
		this.validateForm=function(formObj,fields,URL,action,messageTable,submitType,loadIndicator){

			if($('messageBox')){
				$('messageBox').style.display="none";
			}

			cutFieldParams=fields.split(',');
			
			compareFieldBool=false;compareFieldFirstVal="";ErrorCount=0;
			
			//reseting
			for(i=0;i<cutFieldParams.length;i++){
				getValidType=cutFieldParams[i].split("##");
				eval("document."+formObj+"."+getValidType[0]).className="";
			}
			
			for(i=0;i<cutFieldParams.length;i++){
				getValidType=cutFieldParams[i].split("##");
				if(getValidType[1]=="text"){//blank as text
					if(Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="" || Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="First Name" || Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="Last Name" ){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
					if(getValidType[0]=="uname" && eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						var illegalChars = /\W/;
						if (eval("document."+formObj+"."+getValidType[0]+".value").length < 5) {
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							ErrorCount++;
						} else if (illegalChars.test(eval("document."+formObj+"."+getValidType[0]+".value")))  {
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							ErrorCount++;
						}
					}
				}
				else if(getValidType[1]=="compare"){//compare password
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password required.";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else if(eval("document."+formObj+"."+getValidType[0]+".value").length<6){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password should be Minimum 6 characters.";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
						}
					else if(eval("document."+formObj+".password.value")!=eval("document."+formObj+".confirmPassword.value")){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="Password mismatch";
							$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else{
						if($(getValidType[0]+'Label')){
							$(getValidType[0]+'Label').innerHTML="";
							$(getValidType[0]+'Label').className="grayTextForLabel";
						}
					}
					
				}
				else if(getValidType[1]=="email"){//email validation
					
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Email ID required";
								$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else if(!emailValidation(eval("document."+formObj+"."+getValidType[0]+".value"))){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Valid Email ID required - Special characters[~!#$%^&*(),;'...] are not allowed";
								$(getValidType[0]+'Label').className="mandatoryStar";
						}
						ErrorCount++;
					}
					else{
						if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
						}
					}
				}
				else if(getValidType[1]=="select"){//select box validation
					if(eval("document."+formObj+"."+getValidType[0]+".selectedIndex")==0){
						eval("document."+formObj+"."+getValidType[0]).className="redBorderSelect";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Select from dropdown";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}						
					}
				}
				else if(getValidType[1]=="num"){//numerical validation
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else if(isNaN(eval("document."+formObj+"."+getValidType[0]+".value"))){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should be numerical value";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}//else if
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}						
					}
				}//else if Numerical
				else if(getValidType[1]=="blankNum"){//numerical validation
					if(eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						if(isNaN(eval("document."+formObj+"."+getValidType[0]+".value"))){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should be numerical value";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}	
						}
					}
				}//else if email blank
				else if(getValidType[1]=="notblankEmail"){//numerical validation
					if(eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						if(!emailValidation(eval("document."+formObj+"."+getValidType[0]+".value"))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Please enter a valid email Address";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							
							ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
					}
				}//else if 
				else if(getValidType[1]=="File"){//FILE
				
					if(eval("document."+formObj+"."+getValidType[0]+".value")==""){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
						
						if(!checkExtension(eval("document."+formObj+"."+getValidType[0]))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Accept only '"+ $(getValidType[0]).accept +"' ";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
						
					}
				}
				else if(getValidType[1]=="notblankFile"){//FILE extension validation if not mandatory
					if(eval("document."+formObj+"."+getValidType[0]+".value")!=""){
						if(!checkExtension(eval("document."+formObj+"."+getValidType[0]))){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Accept only '"+ $(getValidType[0]).accept +"' ";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
						}
						else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
						}
					}
					
				}
				else if(getValidType[1]=="date"){
					if (isDate(eval("document."+formObj+"."+getValidType[0]+".value"))==false){
							eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Enter a valid Date";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
	
				}//end of date
				////*This validating List box Multiple Selection required*/
				else if(getValidType[1]=="list"){
						countSel=0;
						for(var j=0; j<eval("document."+formObj+"."+getValidType[0]+".length"); j++) {
							if(eval("document."+formObj+"."+getValidType[0])[j].selected == true){
								countSel++;
							}
						}
						if(countSel<1){
							eval("document."+formObj+"."+getValidType[0]).className="redBorderSelect";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="Select one or more item from list box";
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else if(countSel==1 && eval("document."+formObj+"."+getValidType[0])[0].value=="-1"){
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML=eval("document."+formObj+"."+getValidType[0])[0].text.replace(/--/gi, "");
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else{
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="";
									$(getValidType[0]+'Label').className="grayTextForLabel";
								}						
						}
				}
				////*End of ListBox Validation*/
								////*End of checkBox Validation*/
				else if(getValidType[1]=="check"){
					countChked=0;
						for(var j=0; j<eval("document."+formObj+"."+getValidType[0]+".length"); j++) {
							if(eval("document."+formObj+"."+getValidType[0])[j].checked == true){
								countChked++;
							}
						}	
						if(countChked<1){
							
								//eval("document."+formObj+"."+getValidType[0]+"DIV").className="redBorderSelect";
								$(getValidType[0]+"DIV").className="redBorder";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="Check one or more items";
									$(getValidType[0]+'Label').className="mandatoryStar";
								}
								ErrorCount++;
						}
						else{
								$(getValidType[0]+"DIV").className="";
								if($(getValidType[0]+'Label')){
									$(getValidType[0]+'Label').innerHTML="";
									$(getValidType[0]+'Label').className="grayTextForLabel";
								}						
						}
				}
				
				else if(getValidType[1]=="captcha") {
					if(Trim(eval("document."+formObj+"."+getValidType[0]+".value"))=="" ){
						eval("document."+formObj+"."+getValidType[0]).className="redBorder";
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Security code should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
						ErrorCount++;
					}
					else{
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					}
				
				}
				

				
				/****************************************************************************************/
				/*--- START WYSIWYG----*/
				/* XXXX Very Important for this VALIDATION " TinyMCE WYSIWYG " required. Otherwise error occure  */
				/***************************************************************************************/
				else if(getValidType[1]=="WISIWYG"){
					 
					 if (tinyMCE.getContent(getValidType[0]) == null || tinyMCE.getContent(getValidType[0]) == "") ///This function contain in tiny_mce.js
					 {
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="Should not be blank";
								$(getValidType[0]+'Label').className="mandatoryStar";
							}
							ErrorCount++;
					 }
					 else {
							if($(getValidType[0]+'Label')){
								$(getValidType[0]+'Label').innerHTML="";
								$(getValidType[0]+'Label').className="grayTextForLabel";
							}
					 }
				}
				/**************/
				/* ** END WYSIWYG***  */
				/******************/
				

			}///for
			if(ErrorCount>0){
				if(messageTable=="loginMessage" ){
					
					Effect.Appear("loginMessage");
					$('loginMessageWriterTd').innerHTML='<span><img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"> Username / Password missing</span>'
				}
				else if(messageTable=="fPErrorMessage"){
					Effect.Appear("fPErrorMessage");
					$('fPErrorMessageWriter').innerHTML='<span><img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"> E-mail Id field missing</span>'
					}
				else if(messageTable=="messageBoxB"){
					Effect.Appear("messageBoxB");
					$('messageBoxBWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> Error! Please fill all mandatory fields marked as <span class="mandatoryStar" >*<span> </span>'
					}
				else if($('messageBox')){
					Effect.Appear("messageBox");
					$('messageWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> Error! Please fill all mandatory fields marked as <span class="mandatoryStar" >*<span> </span>'
				}
				
				else if(messageTable=='referMessageBox'){
					$('referMessageWriterTD').innerHTML='<span> <img src="../assets/images/icons/exclamation.gif" width="16" height="16" align="absmiddle"  /> Error! Please fill all mandatory fields marked as <span class="mandatoryStar" >*</span> with valid info </span>'
					Effect.Appear("referMessageBox");
				}
				
			}//if
			else{
				
				
				if(messageTable=="loginMessage" ){
					$('loginMessage').style.display="none";
				}
				else if(messageTable=="fPErrorMessage"){
					$('fPErrorMessage').style.display="none";
					}
				else if($('messageBox')){
					$('messageBox').style.display="none";
				}
				else if($('referMessageBox')){
					$('referMessageBox').style.display="none";
				}
				
				if(submitType=="MULTIPART"){
					Form.enable(formObj);
					$(formObj).action=URL+"?action="+action;
					$(formObj).submit();	
					Form.disable(formObj);
					if($('submitBtn')){
						$('submitBtn').disabled=true;	
					}
				}
				else{
					
					
					
					if (formObj=="registrationForm" || formObj=="newsletterForm" || formObj=="referFriendForm" || formObj=="feedbackForm" ||  formObj=="communityForm"|| formObj=="mailForm"){
						
						Form.disable(formObj);
					}
					
					ObjToClose="";
					printoMaster.CreateAJAXRequest(URL,'noPrintRequired','action='+action+'&ObjIdToClose='+ObjToClose+'&'+Form.serialize(formObj),'NoContent',loadIndicator);
				}
			}//else
		}//Validate function
		
		function emailValidation(ObjValue){
			
			var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			str = ObjValue;
			if(str.match(emailRegEx)){
				return true; 
			}else{
				return false;
			}
			
/*				cutEmailAt=ObjValue.split("@");
				cutEmailDot=ObjValue.split(".");
				if(cutEmailAt.length<2 || cutEmailAt.length>2 ){
					return false;
				}
				else if(cutEmailDot.length<2){
					return false;
				}
				else{
					return true; 
				}
*/		}
		
 		 //extension checking Added on 20th Nov 2007
		function checkExtension(Obj){
				cutAcceptEXT=Obj.accept.split(",");
				dot=Obj.value.lastIndexOf("."); 
				fileNamelength=Obj.value.length
				var extension = Obj.value.substr(dot+1,fileNamelength); 
				checkRightExtension=false;
				for(j=0;j<cutAcceptEXT.length;j++){
					if (Trim(cutAcceptEXT[j])==extension){
						checkRightExtension=true;	
					}
				}
				return checkRightExtension;
		}
		
			//Date Validation
			var dtCh= "/"; ///dd/mm/yyyy
			var minYear=1900;
			var maxYear=2100;
			
			function isInteger(s){
				var i;
				for (i = 0; i < s.length; i++){   
					// Check that current character is number.
					var c = s.charAt(i);
					if (((c < "0") || (c > "9"))) return false;
				}
				// All characters are numbers.
				return true;
			}
			
			function stripCharsInBag(s, bag){
				var i;
				var returnString = "";
				// Search through string's characters one by one.
				// If character is not in bag, append to returnString.
				for (i = 0; i < s.length; i++){   
					var c = s.charAt(i);
					if (bag.indexOf(c) == -1) returnString += c;
				}
				return returnString;
			}
			
			function 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){
				var daysInMonth = DaysArray(12)
				var pos1=dtStr.indexOf(dtCh)
				var pos2=dtStr.indexOf(dtCh,pos1+1)
				var strMonth=dtStr.substring(pos1+1,pos2)
				var strDay=dtStr.substring(0,pos1)
				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 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
					//alert("Please enter a valid date")
					return false
				}
			return true
			}
			
	
///user Action
	this.ConfirmBOX=function(action,uname,URL,param){
		if($('userActionMessage')){
			Element.hide('userActionMessage');
		}
		
		if(action=="enable"){
			ConfVal=confirm("You are about to Enabling account of : "+uname)
			if(ConfVal==1){
				ObjToClose="";
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		else if(action=="disable"){
			ConfVal=confirm("You are about to Disabling account of : "+uname)
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		else if(action=="delete"){
			ConfVal=confirm("You are about to Deleting account of : "+uname)
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}

		}
		else if(action=="enableNewsletter"){
			ConfVal=confirm("You are about to Enabling subscription to: "+uname)
			if(ConfVal==1){
				ObjToClose="";
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		else if(action=="disableNewsletter"){
			ConfVal=confirm("You are about to Disabling subscription to : "+uname)
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		
		/////news updates
		else if(action=="disableNews"){
			ConfVal=confirm("You are about to Disabling this news: \n\n' "+uname+" '")
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		else if(action=="enableNews"){
			ConfVal=confirm("You are about to enable this news: \n\n' "+uname+" '")
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
		else if(action=="deleteNews"){
			ConfVal=confirm("You are about to Delete this news: \n\n' "+uname+" '")
			if(ConfVal==1){
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param+"&uname="+uname,'NoContent');	
			}
		}
	////news over
			
	}
	
	

	this.takeAction=function(action,Obj){
		if($(Obj).selectedIndex==0){
			alert("Error!\n\nChoose Newsletter to "+action)	
		}
		else{
			if(action=="Preview"){
				
				newWindowLetter = window.open("../newsletters/"+$(Obj)[$(Obj).selectedIndex].value+"/NewsLetter.html","NewsletterView","scrollbars=yes,height=600,width=680")
				newWindowLetter.focus( );
			}
			else{
				conf=confirm("Are you sure? action: "+action)
				if (conf) {
				param="action="+action+"&fname="+$(Obj)[$(Obj).selectedIndex].value+"&adminNowAt=newsletterM"
				
					window.setTimeout('location.href="createNupload_newsletter.asp?"+param',100);
				}
			}
		}
		
	}
	
	/////career section
	
	this.setTransparentClass=function(ObjId,ObjClass,action,URL){
	
		if(action=="NoBrowserSpec"){
			$(ObjId).className=ObjClass
		}
		else{
		
			if(browser=="Internet Explorer"){
				$(ObjId).className=ObjClass+"IE";
			}
			else{
				$(ObjId).className=ObjClass+"FF";
			}
			
			if(action==1){
				$(ObjId).onclick=function(){
					location.href=URL;
				}
			}
			else if(action==2){
				$(ObjId).style.cursor = "pointer";
				}
			else{
				$(ObjId).style.cursor = "default";
			}
		}
	}
	
		
	this.selectCareerLeftMenu=function(index,Obj,cssObj){
		getRMTds=$(Obj).getElementsByTagName("td");
		getRMTds[index].className=cssObj;
	}
	
	
	this.careersJobRedirect=function(formObj,cityObj,roleObj,jobType){
		city=eval("document."+formObj+"."+cityObj+".options["+eval("document."+formObj+"."+cityObj+".selectedIndex")+"].text");
		rid=eval("document."+formObj+"."+roleObj+".value");

		
		if(eval("document."+formObj+"."+cityObj+".selectedIndex")==0 ){
			alert("Select prefered City");
		}
		else if(eval("document."+formObj+"."+roleObj+".selectedIndex")==0 || rid=="#"){
			alert("Select your Role");
		}
		else{
			
			cityId=eval("document."+formObj+"."+cityObj+".options["+eval("document."+formObj+"."+cityObj+".selectedIndex")+"].value");
			location.href="jobExploreView.asp?rId="+rid+"&city="+city+"&cityId="+cityId+"&jobType="+jobType;
		}
	}
	
	
	//focus text
	this.focusTextField=function(Obj,textValue){
		if(Obj.value==textValue){
			Obj.value="";
			Obj.style.color="#333333"
		}
		else{
			Obj.style.color="#333333";
		}
			
		Obj.onblur=function(){
			if(Obj.value==""){
				Obj.value=textValue;
				Obj.style.color="#999999"
			}
			else{
				Obj.style.color="#333333";
			}
		}
	}
	
	/***************Newly updated at 26th March 2008*****************/
	this.changeClassName=function(obj,classN){ //changing Css Class of Object as per the call
		$(obj).className=classN;
	}
	
	//tab pos change
	this.tabChange=function(obj,index,classN){
		getAllA=$(obj).getElementsByTagName('a')
		for(i=0;i<getAllA.length;i++){
			getAllA[i].className="";
		}
		
		getAllA[index].className=classN
	}

	//////////***********/
	this.sortlist=function(Obj) {
		var lb = $(Obj)
		arrTexts = new Array();
		arrvalues = new Array();
		
		for(i=0; i<lb.length; i++)  {
		  arrTexts[i] = lb.options[i].text+"####"+lb.options[i].value;
		  //arrvalues[i] = lb.options[i].value;
		}
		
		arrTexts.sort();
		
		for(i=0; i<lb.length; i++)  {
		 	cutArrayTextVal=arrTexts[i].split("####")
		 	lb.options[i].text = cutArrayTextVal[0];
		 	lb.options[i].value = cutArrayTextVal[1];
		}
	}
	/****************************/
	




}
printoMaster=new printoMasterClass();


////////////Functions for //////////////

////////////Functions for Careers admin //////////////
function careerFunctions(){
	///populare City Edit
	this.populateCITYEditFields=function(stateName,cityName,cityId,cityNotes){
		
		$('ifOthers').disabled=true;
		$('ifOthers').value="";
		
		soStateIndex="";
		for(i=0;i<$('stateIN').length;i++){
			if(	$('stateIN')[i].value==stateName){
				soStateIndex=i
			}
		}
		
		$('stateIN').selectedIndex=soStateIndex;
		
		$('stateIN').onchange();
		
		soCityIndex="";
		for(i=0;i<$('citiesIN').length;i++){
			if(	$('citiesIN')[i].value==cityName){
				soCityIndex=i
			}
		}
		if(soCityIndex==""){
			$('citiesIN').selectedIndex=($('citiesIN').length-1);
			$('citiesIN').onchange();
			$('ifOthers').value=cityName;
		}
		else{
			$('citiesIN').selectedIndex=soCityIndex;
		}
		
		$('cityId').value=cityId; $('cityNotes').value=cityNotes;
	}
	///populare City Edit
	
	this.confirmBOX=function(URL,param,message,Type){
		getCONFV=confirm(message);
		if(getCONFV){
			if(Type=="noAjax"){
				location.href=URL+"?"+param
			}
			else{
				printoMaster.CreateAJAXRequest(URL,'noPrintRequired',param,'NoContent');
			}
		}
	}
}

printoCareersMaster=new careerFunctions();

/**********End of function for careers admin**********/