// JavaScript Document



function validateSingnUp()
{
	var sEmpty = "";
	
	if (document.Form1.txtName.value == "" ||document.Form1.txtName.value == "Name")
	{
		sEmpty = sEmpty + "- Name \n";
	}
	
	if (document.Form1.txtEmail.value == "" || document.Form1.txtEmail.value == null)
	{
		sEmpty = sEmpty + "- Email\n";
	}
	else
	{
		if (document.Form1.txtEmail.value.indexOf ('@',0) == -1 || document.Form1.txtEmail.value.indexOf ('.',0) == -1)
			{
				sEmpty = sEmpty + "- The E-Mail field requires a \"@\" and a \".\"be used. Please re-enter your E-Mail address.\n";
			}
	}
//i =document.Form1.txttype;
//	ivalue=i.options[i.selectedIndex].value;
//	
//	if (ivalue == "")
//	{
//		sEmpty = sEmpty + "- Type \n";
//	}	
//	
	var args=false;
	 for(i=0; i<3; i++)
	 {
		if(document.Form1.chkType[i].checked)
			{
				args = true;
				break;
			}
	 }
	
	if(!args)
		sEmpty = sEmpty + "- Select atleast one Type";
	 

	if (sEmpty != "")
	{
			alert("Please Fill in the Following Fields: \n" + sEmpty);
			return false;
	}
	else
		return true;
		
}


function onFocusTxtBox(ths)
{
	//do stuff here

}

//feedback val starts

function Trim(strValue)
{
	return LTrim(RTrim(strValue));
}
function LTrim(strValue)
{
   	var LTRIMrgExp = /^\s */;
   	return strValue.replace(LTRIMrgExp, '');
}
function RTrim(strValue)
{
   	var RTRIMrgExp = /\s *$/;
   	return strValue.replace(RTRIMrgExp, '');
}


//check email using javascript
function checkemail(email)
{
	if (email == "")
  	   	return false;
  	index=email.indexOf("@")
	if(index>0)
	{
		index1=email.indexOf(".",index)
		if(!(index1>index+1 && email.length>index1+2))
		return false
	}
	else
		return false
		if (email.length < 3)
	   	return (false);
		
  	return true
}
function validate_test(){
	rvalue = true;
	errmsg = "";
	
	txtmail = document.getElementById("txtEmail1").value
	txtname = document.getElementById("txtname1").value
	txtComments = document.getElementById("Comments").value
	if(Trim(txtname)==""){
		errmsg += "please enter your name\n";
		document.getElementById("valName").innerHTML = "please enter your name";
		rvalue = false;
	}
	else
	{
		document.getElementById("valName").innerHTML = "";
	}
	
	
	if(Trim(txtComments)=="")
	{
		errmsg += "please enter your comments\n";
		document.getElementById("valComments").innerHTML = "please enter your comments";
		rvalue = false;
	}
	else
	{
		document.getElementById("valComments").innerHTML = "";
		
	}
	
	if(Trim(txtmail)==""){
	errmsg += "please enter your Email\n";
	document.getElementById("valEmail").innerHTML = "please enter your Email";
	rvalue = false;
	}
	else
	{
		if (txtmail.indexOf ('@',0) == -1 || txtmail.indexOf ('.',0) == -1)
			{
				errmsg = errmsg + "Please check your Email address.\n";
				document.getElementById("valEmail").innerHTML = "please check your Email address";
				rvalue = false;
			}
		else
			{
					document.getElementById("valEmail").innerHTML = "";
			}
	}
	
	// please do the remaining validation here  similar to following
	// ensure that each field  have "id" in input tag
	//if(Trim(txtname)==""){
		//errmsg += "please enter name\n";
		//rvalue = false;
	//}
	//
	if(!rvalue){
		//alert(errmsg);
		return rvalue;
	}
	
}

function goToTheURL(id)
{
	var url = "default.asp?action=article&id="+ id;
	window.parent.location.href=url;
}

function goToTheCategory(id)
{
	var url = "default.asp?action=category&id="+ id;
	//window.parent.location.href=url;
}


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;
}



//validate customer feedback form
function CheckForm(ths)
{
	//alert("hi");
//	var Q1,Q2,Q3,Q4,Q5
	
	//validate question 1
	var args = false;
	var rVal=true;
	var str = "Please fill the following fields\n";
	//Questin 1
	for(var i=0;i<=4;i++)
	{
		if(ths.Q1[i].checked)
		{
			args = true;
			break;
		}
	}
	
	if(!args)
	{
		str += " - Question 1\n";
		document.getElementById("valQ1").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ1").innerHTML = "";
	}
	
	//Questin 2
	args = false;
	for(var i=0;i<=4;i++)
	{
		if(ths.Q2[i].checked)
		{
			args = true;
			break;
		}
	}

	if(!args)
	{
		str += " - Question 2\n";
		document.getElementById("valQ2").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ2").innerHTML = "";
	}
	
	
	//Questin 3
	args = false;
	for(var i=0;i<=4;i++)
	{
		if(ths.Q3[i].checked)
		{
			args = true;
			break;
		}
	}
	
	if(!args)
	{
		str += " - Question 3\n";
		document.getElementById("valQ3").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ3").innerHTML = "";
	}
	//Questin 4
	args = false;
	for(var i=0;i<=4;i++)
	{
		if(ths.Q4[i].checked)
		{
			args = true;
			break;
		}
	}
	
	if(!args)
	{
		str += " - Question 4\n";
		document.getElementById("valQ4").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ4").innerHTML = "";
	}
	//Questin 5
	args = false;
	for(var i=0;i<=4;i++)
	{
		if(ths.Q5[i].checked)
		{
			args = true;
			break;
		}
	}
	
	if(!args)
	{
		str += " - Question 5\n";
		document.getElementById("valQ5").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ5").innerHTML = "";
	}
	//Questin 6
	args = false;
	for(var i=0;i<=4;i++)
	{
		if(ths.Q6[i].checked)
		{
			args = true;
			break;
		}
	}
	
	if(!args)
	{
		str += " - Question 6\n";
		document.getElementById("valQ6").innerHTML = "Please answer the this question";
		rVal = false;
	}
	else
	{
		document.getElementById("valQ6").innerHTML = "";
	}
	//question val ends

	txtName = ths.txtName2.value
	txtPosition = ths.txtPosition.value
	txtCompany = ths.txtCompany.value
	txtContactNo = ths.txtContactNo.value
	txtMail = ths.txtEmail2.value
	
	if(Trim(txtName)=="")
	{
		str+= " - Name\n";
		document.getElementById("valName").innerHTML = "Please enter the name";
		rVal=false;
		
	}
	else
	{
		document.getElementById("valName").innerHTML = "";
	}
	if(Trim(txtPosition)=="")
	{
		str+= " - Position\n";
		document.getElementById("valPosition").innerHTML = "Please enter the Position";
		rVal=false;
	}
	else
	{
		document.getElementById("valPosition").innerHTML = "";
	}
	
	if(Trim(txtCompany)=="")
	{
		str+= " - Company\n";
		document.getElementById("valCompany").innerHTML = "Please enter the Company";
		rVal=false;
	}
	else
	{
		document.getElementById("valCompany").innerHTML = "";
	}
	
	if(Trim(txtContactNo)=="")
	{
		str+= " - ContactNo\n";
		document.getElementById("valContactNo").innerHTML = "Please enter the ContactNo";
		rVal=false;
	}
	else
	{
		if(!isInteger(Trim(txtContactNo)))
		{
			str += " - Enter only numbers in Contact No\n";
			document.getElementById("valContactNo").innerHTML = "Please enter only numbers";
			rVal = false;
		}
		else
		{
			document.getElementById("valContactNo").innerHTML = "";
		}
		
	}
	if(Trim(txtMail)=="")
	{
		str+= " - Email\n";
		document.getElementById("valEmail").innerHTML = "Please enter the Email";
		rVal=false;
	}
	else
	{
		if (txtMail.indexOf ('@',0) == -1 || txtMail.indexOf ('.',0) == -1)
			{
				str = str + " - Check your Email format\n";
				document.getElementById("valEmail").innerHTML = "Check your Email format";
				rVal = false;
			}
			else
			{
				document.getElementById("valEmail").innerHTML = "";
			}
	}
	
	if(!rVal)
		{
			//alert(str);
			return false;
		}

	return true;;
}

function changeArticle(ths)
{
		window.location.href = 'default.asp?action=article&id='+ ths.value;
}
function changeArticleAr(ths)
{
		window.location.href = 'tmp_PressReleaseAr.asp?Aid='+ ths.value;
}

//feedback val ends




 // --- disabling text selection by ameer
function detectBrowser()
{

var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)


if ((browser=="Microsoft Internet Explorer") && (version>=4))
  {//alert(browser)
  if (document.all)
	document.onselectstart =  function () { return false; };
  }
else if((browser=="Netscape")&& (version>=4))
  {
  // alert(browser)
document.onmousedown = function () { return false; };
  
  }
 
}
//-----------------

var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 0;
if(isNS) 
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
  if(EnableRightClick==1){ return true; }
  else {alert("Right click option is prohibited");return false; }
}
function mousehandler(e){
  if(EnableRightClick==1){ return true; }
  var myevent = (isNS) ? e : event;
  var eventbutton = (isNS) ? myevent.which : myevent.button;
  if((eventbutton==2)||(eventbutton==3)) return false;
}
function keyhandler(e) {
  var myevent = (isNS) ? e : window.event;
  if (myevent.keyCode==96)
    EnableRightClick = 1;
  return;
}
document.oncontextmenu = mischandler;
document.onkeypress = keyhandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;


window.onload=detectBrowser;


