function valid_contactus(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frmCont.txt_email.value.match(emailPat);
	if(document.frmCont.txt_firstname.value == "")
	{
		alert("Please enter the name.");
		document.frmCont.txt_firstname.focus();
		return false;
	}
	
	if(document.frmCont.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frmCont.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frmCont.txt_email.focus();
			return false;
		}
	}
	if(document.frmCont.txt_comment.value=="")
	{
		alert("Please enter the comment");	
		document.frmCont.txt_comment.focus();
		return false;
	}
	if(document.frmCont.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.frmCont.txt_secu_code.focus();
		return false;
	}
}
function valid_enquiry_submit(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.enquiry.txt_email.value.match(emailPat);
	if(document.enquiry.txt_firstname.value == '')
	{
		alert("Please enter the first name.");
		document.enquiry.txt_firstname.focus();
		return false;
	}
	
	if(document.enquiry.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.enquiry.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.enquiry.txt_email.focus();
			return false;
		}
	}
	if(document.enquiry.txt_comment.value == '')
	{
		alert("Please enter the comment / enquiry.");
		document.enquiry.txt_comment.focus();
		return false;
	}
	if(document.enquiry.txt_secu_code.value == "")
	{
		alert("Please enter the addition of "+first_no+" + "+second_no);
		document.enquiry.txt_secu_code.focus();
		return false;
	}
}

function valid_appoint_submit(first_no,second_no)
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = appoint.txt_email.value.match(emailPat);
	if(document.appoint.txt_yourname.value == '')
	{
		alert("Please enter your name.");
		document.appoint.txt_yourname.focus();
		return false;
	}
	
	if(document.appoint.txt_email.value=="")
	{
		alert("Please enter email address");
		document.appoint.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.appoint.txt_email.focus();
			return false;
		}
	}
	if(document.appoint.txt_comment.value == '')
	{
		alert("Please enter comment / enquiry.");
		document.appoint.txt_comment.focus();
		return false;
	}
	if(document.appoint.txt_secu_code.value == "")
	{
		alert("Please enter addition of "+first_no+" + "+second_no);
		document.appoint.txt_secu_code.focus();
		return false;
	}
}
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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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];}
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function add_to_favorite() {
 title = "IdeaIndia Digital E-book Store"; 
 url = window.location;
 
 	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
function GetXmlHttpObject()
{
	try
	{    // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();  
		return xmlHttp;  
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			return xmlHttp;    
		}
		catch (e)
		{      
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!"+e.message);
				return false;
			}
		}
	}
}

function add_to_wishlist(prod_id)
{
	if(IsNumeric(prod_id)==false)
	{
		return false;
	}
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	}
	var url="add_to_wishlist.php?prod_id="+prod_id;
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState == "complete")
		{
			if(xmlHttp.responseText == "err")
			{
				alert("You have entered the invalid input");
			}
			else
			{
				alert("Your selected books is now added into the Wish List");
			}
			prod_id			= "";
			return false;
		}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
function order_popup(URLStr)
{ 
	var left,top,width,height;
	var popUpWin1 = 0;
	left=200;
	top=100;
	width=800;
	height=600;
	popUpWin1 = open(URLStr, 'order', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	return(popUpWin1);
}
function popup(URLStr,width,height,window_name)
{ 
	
	var left,top;
	var popup_win = 0;
	left=200;
	top=100;
	popup_win = window.open(URLStr,'Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',left='+left+',top='+top+'');
	return(popup_win);
}
