/* CSS Document */
function valid1()
{
	if (document.login.username.value == "") {
		alert("Fill the username field.");
		document.login.username.focus();
		return;
	}
	if (document.login.password.value == "") {
		alert("Fill the password field.");
		document.login.password.focus();
		return;
	}
	else {
		document.login.submit();
	}
}

function validpass()
{
	if (document.password.name.value == "") {
		alert("Fill the  Name field.");
		document.password.name.focus();
		return;
	}
	if (document.password.em.value == "") {
		alert("Fill the Email field.");
		document.password.em.focus();
		return;
	} 
	if ( document.password.em.value.indexOf ('@', 0) == -1 || document.password.em.value.indexOf ('.', 0) == -1 ) {
		  alert("Please enter a valid e-mail");
          document.password.em.focus();
		  return;
        }
		else {
		document.password.submit();
	}
}

function deltext(txtid)
{
	//document.x.entermailtext.value="";
	document.getElementById(txtid).value="";
}
function changeimg(imgid,source)
{
	//document.x.goim.src=source;
	document.getElementById(imgid).src=source;
}

/*AHMAD*/
// JavaScript Document

//For the collapsable menu
var PanelSlideOut = "";
var imgSlideOut = "";
function revelerCacherSousNav(LienId, img){
	var Sub = document.getElementById (LienId+"_sub");
		if(Sub.style.display == "none"){
			//document.getElementById (span).innerHTML="&minus;";
			document.getElementById (img).src="images/minusSign.gif";
			document.getElementById (LienId).className= "listings1on";
			Sub.style.display = "";
			if (PanelSlideOut != "") revelerCacherSousNav(PanelSlideOut, imgSlideOut);
			PanelSlideOut = LienId;
			imgSlideOut = img;
		}
		else
		{
			//document.getElementById (span).innerHTML="+";
			document.getElementById (img).src="images/signPlus.gif";
			document.getElementById (LienId).className= "listings1";
			Sub.style.display = "none";
			PanelSlideOut = "";
		}
	}
	
//for validity	
function valid()
{
	if (document.Contact.name.value == "") {
		alert("Fill the Name field.");
		document.Contact.name.focus();
		return;
	}
	if (document.Contact.Comment.value == "") {
		alert("Fill the Comment field.");
		document.Contact.Comment.focus();
		return;
	}
	else {
		document.Contact.submit();
	}
}
function valid1()
{
	if (document.login.username.value == "") {
		alert("Fill the username field.");
		document.login.username.focus();
		return;
	}
	if (document.login.password.value == "") {
		alert("Fill the password field.");
		document.login.password.focus();
		return;
	}
	else {
		document.login.submit();
	}
}
function valid2()
{
	if (document.forget.username.value == "") {
		alert("Fill the username field.");
		document.forget.username.focus();
		return;
	}
	if (document.forget.password.value == "") {
		alert("Fill the password field.");
		document.forget.password.focus();
		return;
	}
	else {
		document.forget.submit();
	}
}
function validEmail()
{
	if (document.Email.email.value == "") {
		alert("Fill the Email field.");
		document.form1.email.focus();
		return;
	} 
	if ( document.Email.email.value.indexOf ('@', 0) == -1 || document.Email.email.value.indexOf ('.', 0) == -1 ) {
		  alert("Please enter a valid e-mail");
          document.Email.email.focus();
		  return;

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

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_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_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 OldLayer_ID		= "";
var OldImage_ID		= "";
var OldParent_ID	= "";

function ShowHideSubLayer (Layer_ID, Image_ID, ParentTD_ID)
{
	var Sub 		= document.getElementById(Layer_ID);
	var Img			= document.getElementById(Image_ID);
	var ParentTD	= document.getElementById(ParentTD_ID);
	
	if (Sub.style.display == "none")
	{
		Sub.style.display	= "";
		ParentTD.className	= "rowDt";
		Img.src				= "images/button_minus.gif";
		
		if (OldLayer_ID != "") 
			ShowHideSubLayer (OldLayer_ID, OldImage_ID, OldParent_ID);
			
		OldLayer_ID		= Layer_ID;
		OldImage_ID		= Image_ID;
		OldParent_ID	= ParentTD_ID;
	}
	else
	{
		Sub.style.display	= "none";
		ParentTD.className	= "";
		Img.src				= "images/button_plus.gif";
		OldLayer_ID			= "";
	}
}



var OldLayer_ID1		= "";
var OldImage_ID1		= "";
var OldParent_ID1	= "";

function ShowHideSubLayer1 (Layer_ID, Image_ID, ParentTD_ID)
{
	var Sub 		= document.getElementById(Layer_ID);
	var Img			= document.getElementById(Image_ID);
	var ParentTD	= document.getElementById(ParentTD_ID);
	
	if (Sub.style.display == "none")
	{
		Sub.style.display	= "";
		ParentTD.className	= "rowDt";
		Img.src				= "images/pencilimg.jpg";
		
		if (OldLayer_ID1 != "") 
			ShowHideSubLayer (OldLayer_ID1, OldImage_ID1, OldParent_ID1);
			
		OldLayer_ID1		= Layer_ID;
		OldImage_ID1	= Image_ID;
		OldParent_ID1	= ParentTD_ID;
	}
	else
	{
		Sub.style.display	= "none";
		ParentTD.className	= "";
		Img.src				= "images/pencilimg.jpg";
		OldLayer_ID1			= "";
	}
}
/**
 * Confirm Order Deletion
 */

function ConfirmDelete(OrderID, OrderRef)
{
	if (window.confirm('Are you sure you want to cancel order # '+ OrderRef +' ?'))
	{
		document.OrderForm.OrderID.value = OrderID;

		document.OrderForm.submit();
	}
}

/**
 * Confirm Print
 */

function ConfirmPrint(OrderID, OrderRef)
{
	if (window.confirm('Are you sure you want to print invoice of order # '+ OrderRef +' ?'))
		window.open('invoice.php?OrderID='+ OrderID, '', 'scrollbars=yes, width=1020, left = 50, top = 50');
}

/**
 * Get Current Date & Time
 */

function getthedate(Type)
{
	var currDate	= new Date();
	
	var year 		= currDate.getYear();
	if (year < 1000)
		year += 1900;
		
	var month		= currDate.getMonth() + 1;
	if (month < 10)
		month = "0" + month;
		
	var daym		= currDate.getDate();
	if (daym < 10)
		daym = "0" + daym;

	var dn			= "AM";
	var hours		= currDate.getHours();
	
	if (hours >= 12)
		dn = "PM";

	if (hours > 12)
		hours = hours-12;

	if (hours == 0)
		hours = 12;
		
	var minutes		= currDate.getMinutes();
	if (minutes <= 9)
		minutes = "0" + minutes;
		
	var seconds		= currDate.getSeconds();
	if (seconds <= 9)
		seconds = "0" + seconds;

	if (Type == 'Date')
		document.write(daym+'/'+month+'/'+year);
	else if (Type == 'Time')
		document.write(hours+':'+minutes+':'+seconds+' '+dn);
	else
		document.write(daym+'/'+month+'/'+year+' '+hours+':'+minutes+':'+seconds+' '+dn);
}

function isDate(day, month, year, FrmName) {
	day		= eval('document.'+FrmName+'.'+day+'.value');
    month	= eval('document.'+FrmName+'.'+month+'.value');
    year	= eval('document.'+FrmName+'.'+year+'.value');

    if ((month==2 || month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Month "+month+" doesn't have 31 days!");
        return false;
    }

    if ((month == 2) && year) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("February " + year + " doesn't have " + day + " days!");
            return false;
        }
    }
    
    return true; // date is valid
}  

// Update Quantity Link
function UpdateQTY(BId,mode,qt) {
	if (mode=='deleteP'){
		if (window.confirm('Are you sure you want to delete this product from your Basket ?')){
		document.Basket.action	= '_Basket.php?cAction=Browse&'+mode+'=1&BasketDTID='+BId;
		document.Basket.cAction.value = "Browse";
		document.Basket.submit();
		}
	}
	else {
		document.Basket.action	= '_Basket.php?cAction=Browse&'+mode+'=1&BasketDTID='+BId+'&upq='+qt;
		document.Basket.cAction.value = "Browse";
		document.Basket.submit();
	}
}
function targetopener(mylink, closeme, closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=mylink;
if (closeme)window.close();
}

/*for contact us begin*/
function validen()
{
	if(document.Add.Text1.value=="")
	{
		alert('please enter your first name');
		document.Add.Text1.focus();
		return;
	}
	if(document.Add.Text2.value=="")
	{
		alert('please enter your last name');
		document.Add.Text2.focus();
		return;
	}
	if(document.Add.Text3.value=="")
	{
		alert('please enter your email');
		document.Add.Text3.focus();
		return;
	}
	else
	{
		            if (document.Add.Text3.value.indexOf ('@', 0) == -1 || document.Add.Text3.value.indexOf ('.', 0) == -1) 
					{
						alert('please enter your email in a true format');
						document.Add.Text3.focus();
		                return;
					}
	}
	
	if(document.Add.address.value=="")
	{
		alert('please enter your address');
		document.Add.address.focus();
		return;
	}
	if(document.Add.Country.value=="")
	{
		alert('please select your country');
		document.Add.Country.focus();
		return;
	}
	document.Add.submit();
}
function validsend()
{

	if(document.Add.youremail.value=="")
	{
		alert('please enter your email');
		document.Add.youremail.focus();
		return;
	}
	else
	{
		            if (document.Add.youremail.value.indexOf ('@', 0) == -1 || document.Add.youremail.value.indexOf ('.', 0) == -1) 
					{
						alert('please enter your email in a true format');
						document.Add.youremail.focus();
		                return;
					}
	}
	if(document.Add.friendemail.value=="")
	{
		alert('please enter your friend email');
		document.Add.friendemail.focus();
		return;
	}
	else
	{
		            if (document.Add.friendemail.value.indexOf ('@', 0) == -1 || document.Add.friendemail.value.indexOf ('.', 0) == -1) 
					{
						alert('please enter your friend email in a true format');
						document.Add.friendemail.focus();
		                return;
					}
	}
	document.Add.submit();
}
function validsend1()
{
	if(document.Add.yourname.value=="")
	{
		alert('please enter your name');
		document.Add.yourname.focus();
		return;
	}

	if(document.Add.youremail.value=="")
	{
		alert('please enter your email');
		document.Add.youremail.focus();
		return;
	}
	else
	{
		            if (document.Add.youremail.value.indexOf ('@', 0) == -1 || document.Add.youremail.value.indexOf ('.', 0) == -1) 
					{
						alert('please enter your email in a true format');
						document.Add.youremail.focus();
		                return;
					}
	}
	if(document.Add.friendname.value=="")
	{
		alert('please enter your friend name');
		document.Add.friendemail.focus();
		return;
	}
	if(document.Add.friendemail.value=="")
	{
		alert('please enter your friend email');
		document.Add.friendemail.focus();
		return;
	}
	else
	{
		            if (document.Add.friendemail.value.indexOf ('@', 0) == -1 || document.Add.friendemail.value.indexOf ('.', 0) == -1) 
					{
						alert('please enter your friend email in a true format');
						document.Add.friendemail.focus();
		                return;
					}
	}
	document.Add.submit();
}
function reset1()
{
	document.Add.reset();
}
function targetopener(mylink, closeme, closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=mylink;
if (closeme)window.close();
}


function checkemailvalidation()
{
	if(document.barznewsletter.newsletteremail.value.indexOf ('@', 0) == -1 || document.barznewsletter.newsletteremail.value.indexOf ('.', 0) == -1)
	{
		alert('please enter a valid email');
		document.barznewsletter.newsletteremail.focus();
		return;	
	}
	document.barznewsletter.submit();
}
function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

        if (bgcolor=="") {
                bgcolor="#FFFFFF";
        }
        var adj=10
        var w = screen.width;
        var h = screen.height;
        var byFactor=1;

        if(w<740){
          var lift=0.90;
        }
        if(w>=740 & w<835){
          var lift=0.91;
        }
        if(w>=835){
          var lift=0.93;
        }
				/*
        if (imageWidth>w){
          byFactor = w / imageWidth;
          imageWidth = w;
          imageHeight = imageHeight * byFactor;
        }
        if (imageHeight>h-adj){
          byFactor = h / imageHeight;
          imageWidth = (imageWidth * byFactor);
          imageHeight = h;
        }
				*/
        var scrWidth = w-adj;
        var scrHeight = (h*lift)-adj;
/*
        if (imageHeight>scrHeight){
            imageHeight=imageHeight*lift;
          imageWidth=imageWidth*lift;
        }
*/
        var posLeft=0;
        var posTop=0;

        if (hugger == "hug image"){
          if (hugMargin == ""){
            hugMargin = 0;
          }
          var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
          if (scrHeightTemp < scrHeight) {
                scrHeight = scrHeightTemp;
          }
          var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
          if (scrWidthTemp < scrWidth) {
                scrWidth = scrWidthTemp;
          }

          if (scrHeight<100){scrHeight=100;}
          if (scrWidth<100){scrWidth=100;}

          posTop =  ((h-(scrHeight/lift)-adj)/2);
          posLeft = ((w-(scrWidth)-adj)/2);
         }
/*
        if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
                imageHeight=imageHeight-adj;
                imageWidth=imageWidth-adj;
        }
				*/
        posTop = parseInt(posTop);
        posLeft = parseInt(posLeft);
        scrWidth = parseInt(scrWidth);
        scrHeight = parseInt(scrHeight);

        var agt=navigator.userAgent.toLowerCase();
        if (agt.indexOf("opera") != -1){
          var args= new Array();
          args[0]='parent';
          args[1]=imageName;
          var i ; document.MM_returnValue = false;
          for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
        } else {
        newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop+",scrollbars=1");
        newWindow.document.open();
        newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+'>');
        newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
        newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+'>');
        newWindow.document.write('</td></tr></table></body></html>');
        newWindow.document.close();
        newWindow.focus();
        }
}
function checktype(){
	if(document.form1.type.value == 'Book'){
		document.getElementById('booktype').style.display = "";
		document.getElementById('manuscript').style.display = "none";	
	}
	else{
		document.getElementById('manuscript').style.display = "";
		document.getElementById('booktype').style.display = "none";
		
 
	}
}
//For vertical scroll
function initScrollLayer() {
  var wndo = new dw_scrollObj('wn', 'lyr1');
  wndo.setUpScrollbar("dragBar", "track", "v", 1, 1); 
  dw_scrollObj.GeckoTableBugFix('wn');  
	document.getElementById('dragBar').style.display= "none";
 
}
function JustSoPicWindow2(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

        if (bgcolor=="") {
                bgcolor="#FFFFFF";
        }
        var adj=10
        var w = screen.width;
        var h = screen.height;
        var byFactor=1;

        if(w<740){
          var lift=0.90;
        }
        if(w>=740 & w<835){
          var lift=0.91;
        }
        if(w>=835){
          var lift=0.93;
        }
        if (imageWidth>w){
          byFactor = w / imageWidth;
          imageWidth = w;
          imageHeight = imageHeight * byFactor;
        }
        if (imageHeight>h-adj){
          byFactor = h / imageHeight;
          imageWidth = (imageWidth * byFactor);
          imageHeight = h;
        }
        var scrWidth = w-adj;
        var scrHeight = (h*lift)-adj;
        if (imageHeight>scrHeight){
            imageHeight=imageHeight*lift;
          imageWidth=imageWidth*lift;
        }
        var posLeft=0;
        var posTop=0;

        if (hugger == "hug image"){
          if (hugMargin == ""){
            hugMargin = 0;
          }
          var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
          if (scrHeightTemp < scrHeight) {
                scrHeight = scrHeightTemp;
          }
          var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
          if (scrWidthTemp < scrWidth) {
                scrWidth = scrWidthTemp;
          }

          if (scrHeight<100){scrHeight=100;}
          if (scrWidth<100){scrWidth=100;}

          posTop =  ((h-(scrHeight/lift)-adj)/2);
          posLeft = ((w-(scrWidth)-adj)/2);
         }
        if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
                imageHeight=imageHeight-adj;
                imageWidth=imageWidth-adj;
        }
        posTop = parseInt(posTop);
        posLeft = parseInt(posLeft);
        scrWidth = parseInt(scrWidth);
        scrHeight = parseInt(scrHeight);

        var agt=navigator.userAgent.toLowerCase();
        if (agt.indexOf("opera") != -1){
          var args= new Array();
          args[0]='parent';
          args[1]=imageName;
          var i ; document.MM_returnValue = false;
          for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
        } else {
        newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop+"");
        newWindow.document.open();
        newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+'>');
        newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
        newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+'>');
        newWindow.document.write('</td></tr></table></body></html>');
        newWindow.document.close();
        newWindow.focus();
        }
}
