// PHPSitescript.js
//Author: Charles Rivera

  var MenuChoices = new Array(9);



 /**********************************************/

function BrowserInfo()

{

  this.name = navigator.appName;

  this.codename = navigator.appCodeName;

  this.version = navigator.appVersion.substring(0,4);

  this.platform = navigator.platform;

  this.javaEnabled = navigator.javaEnabled();

  this.screenWidth = screen.width;

  this.screenHeight = screen.height;

}

var b = new BrowserInfo();

/*window.alert("Browser Name: "+ b.name);

window.alert("Browser Codename: "+ b.codename);

window.alert("Browser Version: "+ b.version);

window.alert("System Platform: "+ b.platform);*/





        function Loader(){

           //window.alert('Loader function reached');

           

           Customizer();



           var now = document.getElementById('hid');

           //window.alert('his is equal to '+now.value);



           if(window.location =="http://www.hudrivkendo.org/index.php?goto=mem"){

             //window.alert('You are at members.');



             var plz = 1;

             var srch = "MSect"+plz;

    

             while(document.getElementById(srch)){

               //window.alert('Found member box: '+srch);

 

               Appender(srch, "Members",plz);

               plz++;

               srch = "MSect"+plz;

               if(!document.getElementById(srch)){

               plz++;

               srch = "MSect"+plz;   

               }

             }



          }

        }





/*****************************************/

	function Appender(Origin , Target, itnum){

                //window.alert('Appender function reached');



		var Og = document.getElementById(Origin);

                //window.alert('The origin is of type '+ Og.nodeName);

                //window.alert('The '+Og.nodeName+' tag id is: '+Og.getAttribute('id')); 

		

		if(b.name == "Microsoft Internet Explorer"){

			

		//Custom Mail Link	

		Og.childNodes[4].href="javascript: MailBox(\"" +Origin+ "\", \""+itnum+"\")";

                Og.childNodes[4].removeAttribute('target');

		Og.childNodes[4].id = "MailLink" + itnum;

		//window.alert("t3[4].firstchild = " + Og.childNodes[4].nodeName);

		

		}

		else if(b.codename == "Mozilla" && b.name != "Microsoft Internet Explorer"){

					

		//Custom Mail Link

                //window.alert('This tag is '+Og.childNodes[7].nodeName);

		Og.childNodes[7].href="javascript: MailBox(\"" +Origin+ "\" ,\""+itnum+"\")";

                Og.childNodes[7].removeAttribute('target');

		Og.childNodes[7].id = "MailLink" + itnum;

		

		}

		

		//Og.style.visibility="inherit";

		//var tar = document.getElementById(Target);

		//tar.style.height="300px";

	    //tar.appendChild(t3);

                

	}



/******************************************/

      function CloseForm(Parent, FrmTarget){

		  var pr = document.getElementById(Parent);

		  var pm = document.getElementById(FrmTarget);

		  pr.removeChild(pm);

	  }

/******************************************/

	  function MailBox(loc, num){

                //window.alert('MailBox reached with arguments: 1. '+loc+' 2. '+num);



		var MB = document.getElementById("Mail");

		var VB = document.getElementById(loc);

		var idt = VB.id + "Nid";

                var stl = VB.getAttribute('style');

                //window.alert("This section's style is: "+stl);  		



		if(!document.getElementById(idt)){

		VB.setAttribute("style","height='auto'");

				

		/*var tmp = document.createElement("hr");

		tmp.width="30%";

		tmp.style.visibility="hidden";

		VB.appendChild(tmp);*/

		

		//Links Div

		var sp = document.createElement("div");

		sp.style.paddingBottom= "5px";

		sp.style.paddingTop= "0px";

		sp.style.fontSize="14pt";

		sp.style.fontWeight="bold";

		sp.id="LinkSpan"

				

		//Close Form link

		var clos = document.createElement("a");

		clos.id = "Close";

		clos.href = "javascript: CloseForm(\""+ loc +"\" , \""+ idt +"\")";

		var clostxt = document.createTextNode("Close Form");

	        clos.appendChild(clostxt);

		sp.appendChild(clos);

		

		var NM = MB.cloneNode(true);

                NM.id = VB.id + "Nid";

                //window.alert("Member section mail id is "+ NM.id);

		NM.appendChild(sp);



                //Hidden Recipient input

                var hid = document.createElement("input");

                hid.id= "Recip"+num;

                //window.alert("Recip id = "+ hid.id);

                hid.name="Recipient";

                hid.type="hidden";

                hid.value= num;



		if(b.codename == "Mozilla" &&	b.name != "Microsoft Internet Explorer"){

			//var valtx = VB.childNodes[3].firstChild.nodeValue;

		    //window.alert("valtx is " + valtx);

		    //inpt.value = valtx;

	            MB.childNodes[1].childNodes[3].setAttribute("name","CopyRecipient");

                    MB.childNodes[1].childNodes[9].setAttribute("name","CopySender");

		    MB.childNodes[1].childNodes[14].setAttribute("name","CopySubject");

                    MB.childNodes[1].childNodes[17].setAttribute("name","CopyMessage");

                    MB.childNodes[1].childNodes[21].setAttribute("name","CopyToCopy");

		    //window.alert("MB[1].9.name is " + (MB.childNodes[1]).childNodes[3].name);





                     	NM.childNodes[1].appendChild(hid);	

			//TexArea id

                        var kt = "Message"+num;		

                     	NM.childNodes[1].childNodes[17].setAttribute("id",kt);			

			//Subject id

			var ks = "Subject"+num;

                     	NM.childNodes[1].childNodes[14].setAttribute("id",ks);			

			//Sender id

                        var km = "Sender"+num;

                        NM.childNodes[1].childNodes[9].setAttribute("id",km);			

			//window.alert("Sender id is "+ NM.childNodes[1].childNodes[9].id);

			//CopyTo value

                        var ck= NM.id;

                     	NM.childNodes[1].childNodes[21].setAttribute("id","CopyTo"+num);



                     	NM.childNodes[1].childNodes[27].setAttribute("onClick","Formfilter(\'"+hid.id+"\',\'"+km+"\',\'"+ks+"\',\'"+kt+"\',\'"+ck+"\')");		

                     	//window.alert("Form tag is" + NM.childNodes[1].childNodes[21].name);			

                     	//window.alert("Form tag is" + NM.childNodes[1].childNodes[27].onclick);			

		        var lb = NM.childNodes[1].childNodes[1];

			lb.style.paddingRight="85px";

			var tarf = (NM.childNodes[1]).childNodes[3];

			var waltx = (NM.childNodes[1]).childNodes[1];

			//window.alert("waltx = "+ waltx);

			var par = NM.childNodes[1];

			//par.replaceChild(inpt,tarf);

			par.removeChild(tarf);

			par.removeChild(waltx);

		}

		

		if(b.name == "Microsoft Internet Explorer"){

			//var walx = VB.childNodes[1].firstChild.nodeValue;

			//window.alert("walx is " + walx);

			//inpt.value = walx;

			//window.alert("MB[0].0 is " + MB.childNodes[0].childNodes[0].nodeName);

				

			//var wlb = NM.childNodes[0].childNodes[0];

			//wlb.style.paddingRight="85px";

                        NM.childNodes[0].appendChild(hid);

                     	//window.alert("Form tag is" + NM.childNodes[0].nodeName);			

			var warf = (NM.childNodes[0]).childNodes[1];

			var pwr = NM.childNodes[0];

			var walx = NM.childNodes[0].childNodes[0];

			//window.alert("walx is " + walx);

			//pwr.replaceChild(inpt,warf);

			pwr.removeChild(warf);

			pwr.removeChild(walx);

		}

		NM.style.visibility="visible";

		VB.appendChild(NM);

                VB.setAttribute('style', stl);

		

		//Custom Background & Bacground Color

		//VB.style.backgroundImage = "url("+MemberCont[num].background+")";

	        //VB.style.backgroundRepeat = "no-repeat";

		//VB.style.backgroundColor = MemberCont[num].backcolor;

		

		//VB.style.backgroundColor="#85D23E";

		//VB.style.backgroundColor="#FBFAD7";

		}

	  }





/********************************************/

  function Clearform(){



         document.getElementById("Recipient").selectedIndex = 0;

         document.getElementById("Sender").value = "";

         document.getElementById("Subject").value = "";

         document.getElementById("Message").value = "";

         document.getElementById("CopyTo").checked = false;          



}

/********************************************/

   //Custom Pages for different Browsers.



   function Customizer(){

      //window.alert("Customizer reached");

      Custom_TitleBar();

      //Custom_BackgroundSize();

   

   }

/*******************************************/



   function Custom_TitleBar(){

      var browser_name = b.name;

      var browser_codename = b.codename;

      //window.alert("Custom_TitleBar reached\nBrowser Name: "+ browser_name +"\nBrowser CodeName: "+browser_codename);

	  

	  

      if(b.codename == "Mozilla" &&	b.name != "Microsoft Internet Explorer" && b.platform != 'Win32'){

       //window.alert("Mozilla positive");

       //var logo_holder =  document.getElementById("TBarCenter").childNodes[0];

	   

	   var logo_holder =  document.getElementById("TBarCenter");

	   logo_holder.style.top ='5px';

	   //window.alert("Platform is: "+b.platform);

	   

	   //logo_holder.src = 'test_logo_alpha.png';

	   //logo_holder.removeAttribute("height")

	   //logo_holder.removeAttribute("width");

      }

   

   

   }

/********************************************/



   function Custom_BackgroundSize(){

	var currentpage = document.getElementById("hid").value;   

	//var bottom_marker = (document.getElementById("LinkMenu")).posX;

	//window.alert("Current Page: "+ currentpage+"\nBottom X: "+bottom_marker);

	

   }