var button1 = new Image();
button1.src = "../images/aboutus.gif";

var button2 = new Image();
button2.src = "../images/aboutus1.gif";

var button3 = new Image();
button3.src = "../images/services.gif"

var button4 = new Image();
button4.src = "../images/services1.gif"

var button5 = new Image();
button5.src = "../images/contactus.gif"

var button6 = new Image();
button6.src = "../images/contactus1.gif"

var button7 = new Image();
button7.src = "../images/faq.gif"

var button8 = new Image();
button8.src = "../images/faq1.gif"

var button9 = new Image();
button9.src = "../images/sitemap.gif"

var button10 = new Image();
button10.src = "../images/sitemap1.gif"

var button11 = new Image();
button11.src = "../images/registration.gif"

var button12 = new Image();
button12.src = "../images/registration1.gif"

var button13 = new Image();
button13.src = "../images/senift.gif"

var button14 = new Image();
button14.src = "../images/sensex.gif"

var button15 = new Image();
button15.src = "../images/nifty.gif"

function glow(ImgId,NewId){

	document.images[ImgId].src = eval(NewId + ".src");
}




 function dec(ido)
 {
 
   if(document.all)
    {
  document.all(ido).style.backgroundColor="#D1ECC6";
  //document.all(ido).style.linkColor="#000000";
  //document.all(ido).innerHTML="#000000";
      }
        else
        if(document.layers)
        {
     document.layers[ido].document.bgColor="#D1ECC6";   
     //document.all(ido).document.color="#000000";   
          }               
     }
   
   
   function  ndc(idu)
   {
   
     if(document.all)
    {
   document.all(idu).style.backgroundColor="#D0DFF4";
   document.all('top14').style.backgroundColor="#DECB91";
      }
      
      else
        if(document.layers)
        {
     document.layers[idu].document.bgColor="#D0DFF4";   
     document.layers['top14'].document.bgColor="#DECB91";   
          }
   
}


function  ndc1(idu1)
   {
   
     if(document.all)
    {
   document.all(idu1).style.backgroundColor="#DECB91";
   
      }
      
      else
        if(document.layers)
        {
     document.layers[idu1].document.bgColor="#DECB91";   
        
          }
   
}



function drop5()
    {

     if(document.all)
       {
       
        document.all('top1').style.visibility="visible";
        document.all('top1').style.top=98;
       document.all('top1').style.backgroundColor="#D0DFF4";
        document.all('top2').style.visibility="visible";
        document.all('top2').style.top=116;
        document.all('top2').style.backgroundColor="#D0DFF4";
        
        document.all('top3').style.visibility="visible";
        document.all('top3').style.top=131;
        document.all('top3').style.backgroundColor="#D0DFF4";
              
       	 document.all('top4').style.visibility="visible";  
       	 document.all('top4').style.top=148;
       	 document.all('top4').style.backgroundColor="#D0DFF4";           
	hid6();	
	hid7();
        }
        else if(document.layers)
          {
          
           document.layers['top1'].visibility="show";
           document.layers['top1'].top=98;
           document.layers['top2'].visibility="show";
           document.layers['top2'].top=118;
           document.layers['top3'].visibility="show";
           document.layers['top3'].top=138;         		
	         document.layers['top4'].visibility="show";
	         document.layers['top4'].top=158;	
           hid6();
           hid7();
           }

     }

function drop6()
    {

     if(document.all)
       {
       
        document.all('top5').style.visibility="visible";
        document.all('top5').style.top=98;
        document.all('top5').style.backgroundColor="#D0DFF4";
        document.all('top6').style.visibility="visible";
        document.all('top6').style.top=116;
        document.all('top6').style.backgroundColor="#D0DFF4";
        
        document.all('top7').style.visibility="visible";
        document.all('top7').style.top=131;
        document.all('top7').style.backgroundColor="#D0DFF4";
              
       	 document.all('top8').style.visibility="visible";  
       	 document.all('top8').style.top=148;
       	 document.all('top8').style.backgroundColor="#D0DFF4";           
	 hid5();
	 hid7();	
        }
        else if(document.layers)
          {
          
           document.layers['top5'].visibility="show";
           document.layers['top5'].top=98;
           document.layers['top6'].visibility="show";
           document.layers['top6'].top=118;
           document.layers['top7'].visibility="show";
           document.layers['top7'].top=138;         		
	         document.layers['top8'].visibility="show";
	         document.layers['top8'].top=158;	
           hid5();
           hid7();   
           }

}

function drop7()
    {

     if(document.all)
       {
       
        document.all('top9').style.visibility="visible";
        document.all('top9').style.top=98;
        document.all('top9').style.backgroundColor="#D0DFF4";
        document.all('top10').style.visibility="visible";
        document.all('top10').style.top=116;
        document.all('top10').style.backgroundColor="#D0DFF4";
        
        document.all('top11').style.visibility="visible";
        document.all('top11').style.top=131;
        document.all('top11').style.backgroundColor="#D0DFF4";
              
       	 document.all('top12').style.visibility="visible";  
       	 document.all('top12').style.top=148;
       	 document.all('top12').style.backgroundColor="#D0DFF4"; 
       	 
       	 document.all('top13').style.visibility="visible";  
       	 document.all('top13').style.top=166;
       	 document.all('top13').style.backgroundColor="#D0DFF4";         
	 hid5();
	 hid6();	
        }
        else if(document.layers)
          {
          
           document.layers['top9'].visibility="show";
           document.layers['top9'].top=98;
           document.layers['top10'].visibility="show";
           document.layers['top10'].top=118;
           document.layers['top11'].visibility="show";
           document.layers['top11'].top=138;         		
	   document.layers['top12'].visibility="show";
	   document.layers['top12'].top=158;	
	   document.layers['top13'].visibility="show";
	   document.layers['top13'].top=178;
           hid5();
	   hid6();   
           }

     }

function drop8()
    {

     if(document.all)
       {
       
        document.all('top14').style.visibility="visible";
        //document.all('top14').style.top=98;
       document.all('top14').style.backgroundColor="#DECB91";
        }
        else if(document.layers)
          {
          
           document.layers['top14'].visibility="show";
           //document.layers['top14'].top=98;
           
           }

     }

// Determine browser.

var isMinNS4 = (document.layers) ? 1 : 0;
var isMinIE4 = (document.all)    ? 1 : 0;

// These variables will hold the current mouse pointer position.

var mouseX = 0;
var mouseY = 0;

// Set up event capturing.

if (isMinNS4)
  document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = getMousePosition;

function getMousePosition(e) {

  // Save mouse pointer position.

  if (isMinNS4) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  if (isMinIE4) {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  }
  //window.status = mouseX + "," + mouseY;
  //return true;

   
     
  if(document.all)
     {
if(mouseX > 310||  mouseY > 171 || mouseY < 99 ||(mouseX < 44 && mouseY < 99) || mouseX < 44 || (mouseY < 116 && mouseX < 159))
           {
             hid5();
             hid6();
             
           }
     }
     
     else if(document.layers)
     {
     if(mouseX > 310 ||  mouseY > 181 || mouseY < 98 || (mouseX < 44 && mouseY < 99) || mouseX < 44 || (mouseY < 116 && mouseX < 159))
           {
             hid5();
             hid6();
             
           }     
       }       
     
    
   if(document.all)
     {
if(mouseX > 310||  mouseY > 190 || mouseY < 99 ||(mouseX < 44 && mouseY < 99) || mouseX < 44 || (mouseY < 116 && mouseX < 159))
           {
             hid7();
             
           }
     }
     
     else if(document.layers)
     {
     if(mouseX > 310 ||  mouseY > 200 || mouseY < 98 || (mouseX < 44 && mouseY < 99) || mouseX < 44 || (mouseY < 116 && mouseX < 159))
           {
             hid7();
             
           }     
       }    
       
       
       if(document.all)
     {
if(mouseX < 25 || mouseX > 253 || mouseY < 400 || mouseY > 422)
           {
             hid8();
             
           }
     }
     
     else if(document.layers)
     {
     if(mouseX < 25 || mouseX > 253 || mouseY < 400 || mouseY > 422)
           {
             hid8();
             
           }     
       }     
                  
}

   


// functions for hiding layers

function hid5()
    {

     if(document.all)
       {
          document.all('top1').style.visibility="hidden";
          document.all('top2').style.visibility="hidden";
          document.all('top3').style.visibility="hidden";
          document.all('top4').style.visibility="hidden";
        }
        else if(document.layers)
          {
          
           
              document.layers['top1'].visibility="hide";
              document.layers['top2'].visibility="hide";
              document.layers['top3'].visibility="hide";
              document.layers['top4'].visibility="hide";
               
           }

     }

 function hid6()
    {

     if(document.all)
       {
          document.all('top5').style.visibility="hidden";
          document.all('top6').style.visibility="hidden";
          document.all('top7').style.visibility="hidden";
          document.all('top8').style.visibility="hidden";
        }
        else if(document.layers)
          {
          
           
              document.layers['top5'].visibility="hide";
              document.layers['top6'].visibility="hide";
              document.layers['top7'].visibility="hide";
              document.layers['top8'].visibility="hide";
               
           }

     }
 
 
 function hid7()
    {

     if(document.all)
       {
          document.all('top9').style.visibility="hidden";
          document.all('top10').style.visibility="hidden";
          document.all('top11').style.visibility="hidden";
          document.all('top12').style.visibility="hidden";
          document.all('top13').style.visibility="hidden";
        }
        else if(document.layers)
          {
          
           
              document.layers['top9'].visibility="hide";
              document.layers['top10'].visibility="hide";
              document.layers['top11'].visibility="hide";
              document.layers['top12'].visibility="hide";
              document.layers['top13'].visibility="hide";
               
           }

}

function hid8()
    {

     if(document.all)
       {
          document.all('top14').style.visibility="hidden";
          
        }
        else if(document.layers)
          {
                     
              document.layers['top14'].visibility="hide";
                             
           }

}

 
 /*
 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)==""){
		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 ;
		}			







	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');	
}

		// displays the links according to the user request
		function ExeProg(Exchange,PrgNm){
			//alert(Exchange+"="+PrgNm)
			var Prog;
			var selection;
     	   			if(Exchange == "BSE"){
              			if(PrgNm == "GainerLoser"){
                     		Prog = "http://cmlinks.com/mukeshbabu/bse/topgl.asp";
                     	} else if(PrgNm == "Breakers"){
                     		Prog = "http://cmlinks.com/mukeshbabu/bse/breakers.asp";         
                     	} else if(PrgNm == "Decline"){
			                Prog = "http://cmlinks.com/mukeshbabu/bse/advdec.asp";         
			            } else if(PrgNm == "Volume"){
			                Prog = "http://cmlinks.com/mukeshbabu/bse/topvol.asp";         
			            } else if(PrgNm == "Quotes"){
			                Prog = "http://cmlinks.com/mukeshbabu/quotes.asp";         
			            } else if(PrgNm == "HighLow"){
			                Prog = "http://cmlinks.com/mukeshbabu/bse/newhilows.asp";         
			            }
          			} else {
                 		if(PrgNm == "GainerLoser"){
                    		Prog = "http://cmlinks.com/mukeshbabu/nsegl.asp";
                     	} else if(PrgNm == "Breakers"){
                     		Prog = "http://cmlinks.com/mukeshbabu/nsecircuit.asp";         
                     	} else if(PrgNm == "Decline"){
			                Prog = "http://cmlinks.com/mukeshbabu/nseadvdec.asp";         
			            } else if(PrgNm == "Volume"){
			                Prog = "http://cmlinks.com/mukeshbabu/nsetopvol.asp";         
			            } else if(PrgNm == "Quotes"){
			                Prog = "http://cmlinks.com/mukeshbabu/nsequotes.asp";         
			            } else if(PrgNm == "HighLow"){
			                Prog = "http://cmlinks.com/mukeshbabu/nsehl.asp";         
			            }
	      	  		} // end of else

     	document.forms[0].action = Prog;
     	document.forms[0].submit();

	} // end of 

// function check if the radio is selected
function retTrueIfSeleceted(FormNm,PrgNm){
		if(FormNm.R1[0].checked == true)
			ExeProg("BSE",PrgNm)
		else if(FormNm.R1[1].checked == true)
			ExeProg("NSE",PrgNm)
		else
			alert("Select Exchange");				
} // end of function
