/*
 * Project		 :	Bosenet
 * Program Name  :	main.js
 * Resource Name :	Amit Kar
 * Description	 :	Javscript functions handling form validation in all pages
 * 
 * Revision History  ------------------------------
 * #No.		By		Changes
 * 
 * ------------------------------------------------
 */

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	  var http_request = false;

	//Creating the object for specific browser
	function makeRequest(url,functionname)
	{

		http_request = false;

		if (window.XMLHttpRequest) // Mozilla, Safari,...
		{ 
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType)
			{
				http_request.overrideMimeType('text/xml'); 
			}
		}
		else if (window.ActiveXObject) // IE
		{ 
			try
			{
				http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
			}
			catch (e)
			{
				try
				{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}

		if (!http_request)
		{
			alert('Giving up :( Cannot create an XMLHTTP instance');
			return false;
		}

		if(functionname=='alertContents_1')
			http_request.onreadystatechange = alertContents_1;
		
		if(functionname=='alertContents_2')
			http_request.onreadystatechange = alertContents_2;

		if(functionname=='alertContents_3')
			http_request.onreadystatechange = alertContents_3;

		if(functionname=='alertContents_4')
			http_request.onreadystatechange = alertContents_4;

		http_request.open('GET', url, true);
		http_request.send(null);
	}

	function checkMail(str)
	{
		var flag=false;
		var x = str;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) return flag=true;
		else return flag=false;
	}

	function trim(str)
	{  
		while(str.charAt(0) == (" ") )
		{  str = str.substring(1);
		}

		while(str.charAt(str.length-1) == " " )
		{  str = str.substring(0,str.length-1);
		}

		return str;
	}

	function validate()
	{
		var name = '';
		var email = '';
		if(document.frm.txtname.value=="")
		{
			alert('Please enter a name');
			document.frm.txtname.focus();
			
			//return (false);
		}
		else if(document.frm.txtemail.value=="")
		{
			alert("Please enter an email address.");
			document.frm.txtemail.focus();
		}
		else if(checkMail(document.frm.txtemail.value)==false)
		{
			alert("Please enter a correct email address.");
			document.frm.txtemail.focus();
		}
		else
		{
			
			var name = document.frm.txtname.value;
			var email = document.frm.txtemail.value;
			var ran_number= Math.random()*500;
			makeRequest("inc/doinvite.php?name="+name+"&email="+email+"&rnd="+ran_number, 'alertContents_1');
		}
	}

	function doSend()
	{
		if(document.frm1.txtname.value=="")
		{
			alert("Please enter your name");
			document.frm1.txtname.focus();
		}
		else if(document.frm1.txtemail.value=="")
		{
			alert("Please enter your email");
			document.frm1.txtemail.focus();
		}
		else if(checkMail(document.frm1.txtemail.value)==false)
		{
			alert("Please enter a correct email address.");
			document.frm1.txtemail.focus();
		}
		else
		{
			var name = document.frm1.txtname.value;
			var email = document.frm1.txtemail.value;
			var phone = document.frm1.txtphone.value;
			var msg = text2newline(document.frm1.txtmsg.value);
			var ran_number= Math.random()*500;
			makeRequest("inc/send_contactus.php?phone="+phone+"&msg="+msg+"&rnd="+ran_number+"&name="+name+"&email="+email,'alertContents_2');
		}
	}

	function text2newline(intext)
	{
		var inText = intext;
		var newStr='';
		var ord = '';
		var replyLen = inText.length;
		//alert(replyLen);
		var browserVersion=navigator.appName;
		if(browserVersion == 'Netscape')
		{
			for(var i=0; i<replyLen; i++)
			{
				ord = inText.charCodeAt(i);
				if(ord==10)
				{
					newStr = newStr + '<br>';
				}
				else
				{
					newStr = newStr + inText.substr(i,1);
				}
			}//for
		}
		else if(browserVersion == 'Microsoft Internet Explorer')
		{
			for(var i=0; i<replyLen; i++)
			{
				ord = inText.charCodeAt(i);
				if(ord==13 && inText.charCodeAt(i+1)==10)
				{
					newStr = newStr + '<br>';
					i++;
					if(i>=replyLen)
					{
						break;
					}
				}
				else
				{
					newStr = newStr + inText.substr(i,1);
				}
			}//for
		}

		//alert(newStr);

		return newStr;
	}

///*** Finding current page location ***///

var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
//alert(sPage);

///*** Finding current page location ***///


////**** NEWSLETTER SUBSCRIBER SECTION ****////

	//Object for popup
	var myBox = new GlassBox();
	
	//Function for showing data through ajax
	function alertContents_1()
	{
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{    
				document.getElementById("progress").style.display='none';
				myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
				myBox.lbo( false, 0.50 );
				//alert(http_request.responseText);
				if(http_request.responseText=="success")
				{
					document.frm.txtname.value="";
					document.frm.txtemail.value="";
					//myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					//myBox.lbo( false, 0.50 );
					document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel(1)' class='btn'>";
					document.getElementById('pic').innerHTML="Thank you!";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;Thank you!";
					document.getElementById("myBoxstr").innerHTML="Your registration has been successful.";
					//window.scroll(0,0);
				}
				else if(http_request.responseText=="failed")
				{
					document.frm.txtname.value="";
					document.frm.txtemail.value="";
					//myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					//myBox.lbo( false, 0.50 );
					document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel(0)' class='btn'>";
					document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
					document.getElementById("myBoxstr").innerHTML="Your registration unsuccessful. Please try again.";
					//window.scroll(0,0);
				}
			} 
			else
			{
				alert('There was a problem with the HTTP request.\n Please contact site administrator.'); 
			}
		}
	}
	
	var showMyBox = function()
	{
		//myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
		//myBox.lbo( false, 0.50 );
		
		var name = '';
		var email = '';
		if(trim(document.frm.txtname.value)=="")
		{
			myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter a name.';
			//window.scroll(0,0);
		}
		else if(trim(document.frm.txtemail.value)=="")
		{
			myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter an email address.';
			//window.scroll(0,0);
		}
		else if(checkMail(document.frm.txtemail.value)==false)
		{
			myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter a correct email address.';
			//window.scroll(0,0);
		}
		else
		{
			//document.getElementById('pic').innerHTML="";
			//document.getElementById('pic1').innerHTML="";
			document.getElementById("progress").style.display='block';
			submit();
		}
		
		
	};


	var cancel = function (st)
	{
		var name = '';
		var email = '';
		//alert(st);
		if(trim(document.frm.txtname.value)=="")
		{
			document.frm.txtname.focus();
		}
		else if(trim(document.frm.txtemail.value)=="")
		{
			document.frm.txtemail.focus();
		}
		else if(checkMail(document.frm.txtemail.value)==false)
		{
			document.frm.txtemail.focus();
		}
		
		myBox.fadeBox('myBox');

		if(st==1)
		{
			//window.location.href=sPage;
		}
		//window.scroll(0,document.documentElement.scrollTop+70);
	};

	function submit()
	{
		var name = document.frm.txtname.value;
		var email = document.frm.txtemail.value;
		//document.getElementById("chk").value=1;
		var ran_number= Math.random()*500;

		makeRequest("inc/doinvite.php?name="+name+"&email="+email+"&rnd="+ran_number, 'alertContents_1');

		//myBox.fadeBox('myBox');
	}

	////**** NEWSLETTER SUBSCRIBER SECTION ****////

	////**** CONTACT US PAGE SECTION ****////

	//Object for popup
	var myBox1 = new GlassBox();
	
	function alertContents_2()
	{
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{    
				//alert(http_request.responseText);
				if(http_request.responseText=="success")
				{
					document.frm1.txtname.value="";
					document.frm1.txtemail.value="";
					document.frm1.txtphone.value="";
					document.frm1.txtmsg.value="";
					myBox1.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					myBox1.lbo( false, 0.50 );
					document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(1)' class='btn'>";
					document.getElementById('pic1').innerHTML="Thank you for your message.";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;Thank you!";
					document.getElementById("myBoxstr1").innerHTML="We will get in touch with you shortly.";
					//window.scroll(0,0);
				}
				else if(http_request.responseText=="failed")
				{
					document.frm1.txtname.value="";
					document.frm1.txtemail.value="";
					document.frm1.txtphone.value="";
					document.frm1.txtmsg.value="";
					myBox1.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					myBox1.lbo( false, 0.50 );
					document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
					document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
					document.getElementById("myBoxstr1").innerHTML="Your message sending is unsuccessful. Please check inputs and try again.";
					//window.scroll(0,0);
				}
			} 
			else
			{
				alert('There was a problem with the HTTP request.\n Please contact site administrator.'); 
			}
		}
	}
	
	var showMyBoxContact = function()
	{
		//myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
		//myBox1.lbo( false, 0.50 );
		
		var name = '';
		var email = '';
		if(trim(document.frm1.txtname.value)=="")
		{
			myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
			myBox1.lbo( false, 0.50 );
			document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
			document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr1").innerHTML='Please enter a name.';
		}
		else if(trim(document.frm1.txtemail.value)=="")
		{
			myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
			myBox1.lbo( false, 0.50 );
			document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
			document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr1").innerHTML='Please enter an email address.';
		}
		else if(checkMail(document.frm1.txtemail.value)==false)
		{
			myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
			myBox1.lbo( false, 0.50 );
			document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
			document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr1").innerHTML='Please enter a correct email address.';
		}
		else if(trim(document.frm1.txtphone.value)=="")
		{
			myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
			myBox1.lbo( false, 0.50 );
			document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
			document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr1").innerHTML='Please enter your phone number.';
		}
		else if(trim(document.frm1.txtmsg.value)=="")
		{
			myBox1.init( 'myBox1', '370px', '200px', 'hidden', '', true, true );
			myBox1.lbo( false, 0.50 );
			document.getElementById('cbtn1').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel1(0)' class='btn'>";
			document.getElementById('pic1').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr1").innerHTML='Please enter your message.';
		}
		else
		{
			//document.getElementById('pic1').innerHTML="";
			//document.getElementById('pic1').innerHTML="";
			//document.getElementById("myBoxstr1").innerHTML='';
			submit1();
		}
		
		//window.scroll(0,0);
	};


	function submit1()
	{
		var name = document.frm1.txtname.value;
		var email = document.frm1.txtemail.value;
		var phone = document.frm1.txtphone.value;
		var msg = text2newline(document.frm1.txtmsg.value);
		var ran_number= Math.random()*500;
		makeRequest("inc/send_contactus.php?phone="+phone+"&msg="+msg+"&rnd="+ran_number+"&name="+name+"&email="+email,'alertContents_2');

		//myBox1.fadeBox('myBox1');
	}

	var cancel1 = function (st)
	{
		var name = '';
		var email = '';
		if(trim(document.frm1.txtname.value)=="")
		{
			document.frm1.txtname.focus();
		}
		else if(trim(document.frm1.txtemail.value)=="")
		{
			document.frm1.txtemail.focus();
		}
		else if(checkMail(document.frm1.txtemail.value)==false)
		{
			document.frm1.txtemail.focus();
		}
		else if(trim(document.frm1.txtphone.value)=="")
		{
			document.frm1.txtphone.focus();
		}
		else if(trim(document.frm1.txtmsg.value)=="")
		{
			document.frm1.txtmsg.focus();
		}
		
		myBox1.fadeBox('myBox1');
		//window.scroll(0,document.documentElement.scrollTop+260);
		if(st==1)
		{
			//window.location.href=sPage;
		}
	};

	function clearBox()
	{
		//document.getElementById('msg').innerHTML=""
		//document.getElementById('msg').style.display="none";
	}

	////**** CONTACT US PAGE SECTION ****////

	
	////**** CONTACT US MODULE SECTION ****////
	
	//Object for popup
	var myBox2 = new GlassBox();

	function alertContents_3()
	{
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{    
				document.getElementById("progress1").style.display='none';
				//alert(http_request.responseText);
				if(http_request.responseText=="success")
				{
					document.frmCon.txtname1.value="";
					document.frmCon.txtemail1.value="";
					//document.frmCon.txtphone.value="";
					document.frmCon.txtmsg1.value="";
					myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
					myBox2.lbo( false, 0.50 );
					document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(1)' class='btn'>";
					document.getElementById('pic2').innerHTML="Thank you for your message.";
					//document.getElementById('pic2').innerHTML="&nbsp;&nbsp;Thank you!";
					document.getElementById("myBoxstr2").innerHTML="We will get in touch with you shortly.";
					//window.scroll(0,0);
				}
				else if(http_request.responseText=="failed")
				{
					document.frmCon.txtname1.value="";
					document.frmCon.txtemail1.value="";
					//document.frmCon.txtphone.value="";
					document.frmCon.txtmsg1.value="";
					myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
					myBox2.lbo( false, 0.50 );
					document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(0)' class='btn'>";
					document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
					//document.getElementById('pic2').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
					document.getElementById("myBoxstr2").innerHTML="Your message sending is unsuccessful. Please check inputs and try again.";
					//window.scroll(0,0);
				}
			} 
			else
			{
				alert('There was a problem with the HTTP request.\n Please contact site administrator.'); 
			}
		}
	}
	
	var showBoxContact = function()
	{
		//myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
		//myBox2.lbo( false, 0.50 );
		
		var name = '';
		var email = '';
		if(trim(document.frmCon.txtname1.value)=="")
		{
			myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
			myBox2.lbo( false, 0.50 );
			document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(0)' class='btn'>";
			document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr2").innerHTML='Please enter a name.';
		}
		else if(trim(document.frmCon.txtemail1.value)=="")
		{
			myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
			myBox2.lbo( false, 0.50 );
			document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(0)' class='btn'>";
			document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr2").innerHTML='Please enter an email address.';
		}
		else if(checkMail(document.frmCon.txtemail1.value)==false)
		{
			myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
			myBox2.lbo( false, 0.50 );
			document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(0)' class='btn'>";
			document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr2").innerHTML='Please enter a correct email address.';
		}
		/*else if(trim(document.frmCon.txtphone.value)=="")
		{
			document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2()' class='btn'>";
			document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr2").innerHTML='Please enter your phone number.';
		}*/
		else if(trim(document.frmCon.txtmsg1.value)=="")
		{
			myBox2.init( 'myBox2', '370px', '200px', 'hidden', '', true, true );
			myBox2.lbo( false, 0.50 );
			document.getElementById('cbtn2').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel2(0)' class='btn'>";
			document.getElementById('pic2').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr2").innerHTML='Please enter your message.';
		}
		else
		{
			//document.getElementById('pic2').innerHTML="";
			//document.getElementById('pic1').innerHTML="";
			//document.getElementById("myBoxstr2").innerHTML='';
			document.getElementById("progress1").style.display='block';
			submitCon();
		}
		
		//window.scroll(0,0);
	};

	function submitCon()
	{
		var name = document.frmCon.txtname1.value;
		var email = document.frmCon.txtemail1.value;
		//var phone = document.frmCon.txtphone1.value;
		var phone = "";
		var msg = text2newline(document.frmCon.txtmsg1.value);
		var ran_number= Math.random()*500;
		makeRequest("inc/send_contactus_module.php?phone="+phone+"&msg="+msg+"&rnd="+ran_number+"&name="+name+"&email="+email,'alertContents_3');

		//myBox2.fadeBox('myBox2');
	}

	var cancel2 = function (st)
	{
		var name = '';
		var email = '';
		if(trim(document.frmCon.txtname1.value)=="")
		{
			document.frmCon.txtname1.focus();
		}
		else if(trim(document.frmCon.txtemail1.value)=="")
		{
			document.frmCon.txtemail1.focus();
		}
		else if(checkMail(document.frmCon.txtemail1.value)==false)
		{
			document.frmCon.txtemail1.focus();
		}
		/*else if(trim(document.frmCon.txtphone1.value)=="")
		{
			document.frmCon.txtphone1.focus();
		}*/
		else if(trim(document.frmCon.txtmsg1.value)=="")
		{
			document.frmCon.txtmsg1.focus();
		}
		
		myBox2.fadeBox('myBox2');
		//window.scroll(0,document.documentElement.scrollTop+260);
		//window.scroll(0,0);
		if(st==1)
		{
			//window.location.href=sPage;
		}
	};
	
	function clearBoxContact()
	{
		//document.getElementById('msg').innerHTML=""
		document.getElementById('msgContact').style.display="none";
	}

	function showDiv(theDiv)
	{
		if(theDiv=="email")
		{
			if (document.getElementById)
			{ // DOM3 = IE5, NS6
				document.getElementById('phone').style.display = "none";
			}
			else if (document.all)
			{ // IE 4, Firefox
				document.all.phone.style.display = "none";
			}
		}
		else
		{
			if (document.getElementById)
			{ // DOM3 = IE5, NS6
				document.getElementById('email').style.display = "none";
			}
			else if (document.all)
			{ // IE 4, Firefox
				document.all.email.style.display = "none";
			}
		}
		
		if (document.getElementById)
		{ // DOM3 = IE5, NS6
			document.getElementById(theDiv).style.display = (document.getElementById(theDiv).style.display == "none")?"block":"none";
		}
		else if (document.all)
		{ // IE 4, Firefox
			document.all.theDiv.style.display = (document.all.theDiv.style.display == "none")?"block":"none";
		}
	}

	////**** CONTACT US MODULE SECTION ****////


	////**** DOWNLOAD SUBSCRIBER SECTION ****////

	//Object for popup
	var myBox3 = new GlassBox();
	
	//Function for showing data through ajax
	function alertContents_4()
	{
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{    
				//document.getElementById("progress").style.display='none';
				myBox3.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
				myBox3.lbo( false, 0.50 );
				//alert(http_request.responseText);
				if(http_request.responseText=="success")
				{
					document.frm1.txtname.value="";
					document.frm1.txtemail.value="";
					document.frm1.chksubs.checked = false;
					//myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					//myBox.lbo( false, 0.50 );
					document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel3(1)' class='btn'>";
					document.getElementById('pic').innerHTML="Thank you!";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;Thank you!";
					document.getElementById("myBoxstr").innerHTML="Your registration has been successful.";
					//window.scroll(0,0);
				}
				else if(http_request.responseText=="failed")
				{
					document.frm1.txtname.value="";
					document.frm1.txtemail.value="";
					document.frm1.chksubs.checked = false;
					//myBox.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
					//myBox.lbo( false, 0.50 );
					document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel3(0)' class='btn'>";
					document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
					//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
					document.getElementById("myBoxstr").innerHTML="Your registration unsuccessful. Please try again.";
					//window.scroll(0,0);
				}
			} 
			else
			{
				alert('There was a problem with the HTTP request.\n Please contact site administrator.'); 
			}
		}
	}
	
	var showMyBoxReg = function()
	{
		//myBox3.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
		//myBox3.lbo( false, 0.50 );
		
		var name = '';
		var email = '';
		if(trim(document.frm1.txtname.value)=="")
		{
			myBox3.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox3.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel3(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter a name.';
			//window.scroll(0,0);
		}
		else if(trim(document.frm1.txtemail.value)=="")
		{
			myBox3.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox3.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel3(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter an email address.';
			//window.scroll(0,0);
		}
		else if(checkMail(document.frm1.txtemail.value)==false)
		{
			myBox3.init( 'myBox', '370px', '200px', 'hidden', '', true, true );
			myBox3.lbo( false, 0.50 );
			document.getElementById('cbtn').innerHTML="<INPUT TYPE='button' name='' value=' OK ' onclick='cancel3(0)' class='btn'>";
			document.getElementById('pic').innerHTML="<img src='images/exclaim.gif' />&nbsp;<font color='#980106'>ALERT !</font>";
			//document.getElementById('pic1').innerHTML="&nbsp;&nbsp;&nbsp;<font color='#980106'>ALERT !</font>";
			document.getElementById("myBoxstr").innerHTML='Please enter a correct email address.';
			//window.scroll(0,0);
		}
		else
		{
			submit3();
		}
		
		
	};


	var cancel3 = function (st)
	{
		var name = '';
		var email = '';
		//alert(st);
		if(trim(document.frm1.txtname.value)=="")
		{
			document.frm1.txtname.focus();
		}
		else if(trim(document.frm1.txtemail.value)=="")
		{
			document.frm1.txtemail.focus();
		}
		else if(checkMail(document.frm1.txtemail.value)==false)
		{
			document.frm1.txtemail.focus();
		}
		
		myBox3.fadeBox('myBox');
		var filename = document.frm1.filename.value;

		if(st==1)
		{
			window.location.href="download_files.php?f="+filename;
		}
		//window.scroll(0,document.documentElement.scrollTop+70);
	};

	function submit3()
	{
		var name = document.frm1.txtname.value;
		var email = document.frm1.txtemail.value;
		var filename = document.frm1.filename.value;
		
		if (document.frm1.chksubs.checked)
			var subs = "1";
		else
			var subs = "0";

		
		/*for (var f = 0; f < document.forms.length; f++)
		{
			for (var e = 0; e < document.forms[f].elements.length; e++) 
			{
				//
				alert(document.forms[f].elements[e].name);
			}
		}*/
		
		var ran_number= Math.random()*500;

		makeRequest("inc/insert_user_details.php?name="+name+"&email="+email+"&rnd="+ran_number+"&subs="+subs+"&filename="+filename, 'alertContents_4');

		//myBox3.fadeBox('myBox');
	}

	////**** DOWNLOAD SUBSCRIBER SECTION ****////

