// JavaScript Document
function LTrim( value ) 
{ 
 var re = /\s*((\S+\s*)*)/;
 return value.replace(re, "$1"); 
}
// Removes ending whitespaces
function RTrim( value ) 
{
 
 var re = /((\s*\S+)*)\s*/;
 return value.replace(re, "$1");
 
}

// Removes leading and ending whitespaces
function trim( value ) 
{ 
	 return LTrim(RTrim(value)); 
}
function checkchar(mystr,invalidChars1)
{
	for (i=0; i<invalidChars1.length; i++) // does it contain any invalid characters?

		{

			badChar1 = invalidChars1.charAt(i)

			if (mystr.indexOf(badChar1,0) > -1) 

				{

					return false;

				}

		}

return true;

}

function popUp(url)

{
	
	window.open (url,"mywindow","resizable=yes, scrollbars=yes");

}
function IsNumeric(str)

   {

	   var strValidChars = "0123456789";

	   var strChar;

	   var strString = str ;

	   var blnResult = true;

	   var field;



	   if (strString.length == 0) return false;

	

	   //  test strString consists of valid characters listed above

	   for (i = 0; i < strString.length && blnResult == true; i++)

		  {

		  strChar = strString.charAt(i);

		  if (strValidChars.indexOf(strChar) == -1)

			 {

			 	//alert('This value should be Numeric!');

				//field.value = "";

				blnResult = false;

			 }

		  }

	   return blnResult;

   }	//	End	of function IsNumeric

function IsPriceNumeric(str)

   {

	   var strValidChars = "0123456789.";

	   var strChar;

	   var strString = str ;

	   var blnResult = true;

	   var field;



	   if (strString.length == 0) return false;

	

	   //  test strString consists of valid characters listed above

	   for (i = 0; i < strString.length && blnResult == true; i++)

		  {

		  strChar = strString.charAt(i);

		  if (strValidChars.indexOf(strChar) == -1)

			 {

			 	//alert('This value should be Numeric!');

				//field.value = "";

				blnResult = false;

			 }

		  }

	   return blnResult;

   }	//	End	of function IsNumeric



function isNumber (id,val)

{

	if(document.getElementById(id).value != "")

	{

		if( IsNumeric (document.getElementById(id).value) == false )

		{

			alert("Only numeric values are allowed");

			document.getElementById(id).value = val;

			

		}

	}

}
function isPriceNumber (id,val)
{
	if(document.getElementById(id).value != "")
	{
		if( IsPriceNumeric (document.getElementById(id).value) == false )
		{
			alert("Only numeric values are allowed.");
			document.getElementById(id).value = val;
			
		}
	}
}

function eSubscribe()
{
	
	if(trim(document.frmSubscribe.txtemail.value) == "")	

	{

		alert("Please write your email");	

		document.frmSubscribe.txtemail.focus();

	}

	else if (document.frmSubscribe.txtemail.value.indexOf('@',0) < 0 || document.frmSubscribe.txtemail.value.indexOf('.',0) < 0 || !checkchar(document.frmSubscribe.txtemail.value," ?/:,;=+'\"<>|\\`~{}#$%!^&*()"))

	{

		alert("You have given invalid email address");

		document.frmSubscribe.txtemail.focus();

	}
	else
	{
		
		document.frmSubscribe.submit();
	}

}
function ChangeFont(id, change){
	//alert('id');
var block = document.getElementsByTagName('body')[0];

var font_size = parseInt(block.style.fontSize);
alert(block);
alert(font_size);
if (change == "increase"){
font_size = font_size + 2;
block.style.fontSize = font_size + "px";
}
if (change == "decrease"){
font_size = font_size - 2;
block.style.fontSize = font_size + "px";
}
}

function subLogin()
{
	if(trim(document.hdrlogin.hdrId.value) == "")
	{
		alert("Please provide login id/email.");
		document.hdrlogin.hdrId.focus();
	}
	else if(trim(document.hdrlogin.hdrPwd.value) == "")
	{
		alert("Please provide password.");
		document.hdrlogin.hdrPwd.focus();
	}
	else 
	{
		
		document.hdrlogin.submit();
	}
	
	
	
}
function resizeText(multiplier) { 

  if (document.body.style.fontSize == "") { 

    document.body.style.fontSize = "1.0em"; 

  } 

  document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em"; 
 
}
