 
 /*
 Function called on event mouseover and mouseout.
 Function receives imagename,targetimage as arguments.
 Assigns source file to the object
 */

// function to validate the form

 function glow(imgDocID,imgObjName)	{ 
	document.images[imgDocID].src = eval(imgObjName + ".src")
	}            

function SetFocus(){
 document.forms[1].txtUserId.focus();
 }

function isNull(FieldName){
	if(FieldName.charAt(0)==0){
		return true;
	}
	else{
		return false;
	}
 }
 
// function validates the username nd passwords fields
function check(FormNm,ActionType){
			
			// if the first box is seleceted i.e. for NSE/BSE
			//if(FormNm.ExcNm[0].checked == true){
			//	FormNm.action = "../LoginModule/index..php";
			//}	else { // NSDL login
			//	FormNm.action = "../NSDL/NSDLModule..php";
			//}
			
			if(FormNm.cmbAffCode.selectedIndex == 0 && FormNm.ExcNm[0].checked == true){
				alert("Please Select Affiliates Name ");
				FormNm.cmbAffCode.focus();
				//return false;
			} else if(isNull(FormNm.txtUserId.value)){
				alert("Please Enter Valid UserId");
				FormNm.txtUserId.value="";
				FormNm.txtUserId.focus();
				//return false;
			}
			else if(isNull(FormNm.txtPassword.value)){
				alert("Please Enter Valid Password");
				FormNm.txtPassword.value=""
				FormNm.txtPassword.focus();
				//return false;
			}
			else{
			  FormNm.ActionType.value = ActionType; 
				FormNm.submit();
			}
}

// function submits the form
//

function SubmitForm(FormNm,Action,ActionType,Exchange){
//alert(CookieVal);
//alert(Action);
	var  mes1 = "You are currently logged on as NSDL user. If you want to access your ";
		 mes1 =  mes1 + " NSE/BSE data, then first log out from NSDL and login with your NSE/BSE username and password. ";

	var  mes2 = "You are currently logged on as NSE/BSE user. If you want to access your ";
		 mes2 =  mes2 + " NSDL data then first log out from NSE/BSE and login with your NSDL username and password. ";
//alert(ActionType);
	var submit = false;

	FormNm.target="";
	if(ActionType =="ChangePassWd")
			submit = true;
	if(ActionType == "NewsDet")
		FormNm.target="main1";

	if(CookieVal == "LogOn"){ // logged on to NSE/BSE then
		if(Exchange =="NSDL" && ActionType !="OpenDemat"){ // trying to access NSDL Pages
			alert(mes2); 
		} else {
			submit = true ;
		}	
	} else if(CookieVal == "LogOnNSDL"){  					// logged on as a NSDL user
		if(Exchange =="NSDL"){ 	// trying to access NSDL Pages
			submit = true ;
		} else {
			alert(mes1);
		}
	} else {
			submit = true;
		}			
		

//alert(submit);
	if(submit){
			FormNm.action = Action; 
			FormNm.ActionType.value = ActionType;
			if(ActionType != 'LogoutUser' && ActionType !='ForgotPassWd' 
				&& ActionType !='ChangePassWd'){
					FormNm.Exchange.value = Exchange;
				}		
			FormNm.submit();
	}		


}    

// open window for news details.
function OpenWin(FormNm,Url,NewsId){
	FormNm.NewsId.value = NewsId;
	
	var Action = Url+"?News_Id="+NewsId;
	NewWin = window.open(Action,'NewsDet','toolbars=no,width=600,height=400');	
}