function showcommentcontent(name1)
{
	var divstyle = new String();
        divstyle = document.getElementById(name1).style.display;
        if(divstyle.toLowerCase()=="" || divstyle == "")
        {
            document.getElementById(name1).style.display = "none";
        }
        else
        {
            document.getElementById(name1).style.display = "";
        }
	
}

//popup for login-----------------------------------------------------------
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
			function AlreadyExist(str)
			{
			
if (str=="")
  {
  //document.getElementById("divAlbum").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  returnval=false;
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		 submitform(xmlhttp.responseText);
    }
  }
  //alert(xmlhttp.onreadystatechange);
xmlhttp.open("GET","checkemail.php?email="+str,true);
xmlhttp.send();

			}
			
		function Addtonewsletter()
			{
			str=document.getElementById("inputCustom1EMail").value;
if (str=="")
  {
  //document.getElementById("divAlbum").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  returnval=false;
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		 document.getElementById('successmsg').innerHTML=xmlhttp.responseText;
    }
  }
  //alert(xmlhttp.onreadystatechange);
xmlhttp.open("GET","addtonewsltr.php?email="+str,true);
xmlhttp.send();

			}			
function submitform(chk)
{

 if(chk==1)
  {
  Addtonewsletter();
 // ModalPopups.Close("idCustom1");
  }
  else if (chk==0)
  {
    alert("You are already subscribed for the newsletter");
	ModalPopups.Close("idCustom1");
  }
}		
				function ModalPopupsCustom1() {
					ModalPopups.Custom("idCustom1",
						"<center>Newsletter Sign up</center>",
						"<div style='padding: 10px; height:70px;'><div style='color:green; font-size:11px; font-weight:bold;' id='successmsg'></div>" + 
						"<form action='<?php echo $SITE_URL;?>' method='post' name='newsletter'><table>" + 
						
						"<tr><td>E-Mail</td><td><input type=text id='inputCustom1EMail' style='width:200px;' name='email'><input type='hidden' name='newsltr' value='1'></td></tr>" + 
						"</table></form>" + 
						"</div>", 
						{
							//width: 500,
							buttons: "ok,cancel",
							okButtonText: "Save",
							cancelButtonText: "Cancel",
							onOk: "ModalPopupsCustom1Save()",
							onCancel: "ModalPopupsCustom1Cancel()"
						}
					);
							
					ModalPopups.GetCustomControl("inputCustom1EMail").focus(); 
				}
				
				function ModalPopupsCustom1Save() {
					var custom1Name = ModalPopups.GetCustomControl("inputCustom1EMail"); 
					if(custom1Name.value == "")
					{
						alert("Please submit a Email to this form");
						custom1Name.focus();
					}
					else
					{
					  
						/*alert("Your name is: " + custom1Name.value);*/
						if(echeck(custom1Name.value))
						{
						
						AlreadyExist(custom1Name.value);
						}
						
						
					}
				}
				
				function ModalPopupsCustom1Cancel() {
					//alert('You pressed Cancel');
					ModalPopups.Cancel("idCustom1");
				}
//-----------------------------------------------------------------------------------------------


//---------------------popup for register=========================================================
				function ModalPopupsAlert1() {
					ModalPopups.Custom("iAlert1",
						"Register Kirsten Devies",
						"<form action='register.php' name='register' method='post'>"+
						"<div style='padding: 25px;'>" + 
						"<table>" + 
						"<tr><td>User Name</td><td><input type=text id='username' style='width:250px;' name='username'></td></tr>" + 
						"<tr><td>Password</td><td><input type=password name='password' id='passwd' style='width:250px;'></td></tr>"+
						"<tr><td>First Name</td><td><input type=text id='firstname' style='width:250px;' name='firstname'></td></tr>"+
						"<tr><td>Last Name</td><td><input type=text id='lastname' name='lastname' style='width:250px;'></td></tr>"+
						"<tr><td>Email</td><td><input type=text id='email'  name= 'email' style='width:250px;'></td></tr>" + 
						"</table></form>" + 
						"</div>", 
						{
							width: 500,
							buttons: "ok,cancel",
							okButtonText: "Save",
							cancelButtonText: "Cancel",
							onOk: "ModalPopupsCustom2Save()",
							onCancel: "ModalPopupsCustom2Cancel()"
						}
					);
							
					//ModalPopups.GetCustomControl("inputCustom1Name").focus(); 
				}
					function ModalPopupsCustom2Save() {
					var custom1Name = ModalPopups.GetCustomControl("username"); 
					if(custom1Name.value == "")
					{
						alert("Please submit a name to this form");
						custom1Name.focus();
					}
					else
					{
						alert("Your name is: " + custom1Name.value);
						ModalPopups.Close("iAlert1");
					}
				}
				
				function ModalPopupsCustom2Cancel() {
					//alert('You pressed Cancel');
					ModalPopups.Cancel("iAlert1");
				}
				function ModalPopupsConfirmNo() {
					//alert('You pressed No');
					ModalPopups.Cancel("idCustom2");
				}
//=--------------------------------------------------------------------------------------------------				

	function ModalPopupsAlert2(blogid,replyid) {
					ModalPopups.Custom("iAlert2",
						"Register Kirsten Devies",
						"<form action='postcomment.php' name='post_comment' method='post'>"+
						"<input type='hidden' name='blogid' value='"+blogid+"'>"+
						"<input type='hidden' name='replyid' value='"+replyid+"'>"+
						"<div style='padding: 25px;'>" + 
						"<table>" + 
						"<tr><td>Subject</td><td><input type=text id='Subject' style='width:250px;'></td></tr>" + 
						"<tr><td>Comment</td><td><textarea id='Comment' style='width:250px;'></td></tr>" + 
						"</table>" +
						"</form>"+
						"</div>", 
						{
							width: 500,
							buttons: "ok,cancel",
							okButtonText: "Save",
							cancelButtonText: "Cancel",
							onOk: "ModalPopupsCustom3Save()",
							onCancel: "ModalPopupsCustom3Cancel()"
						}
					);
							
					//ModalPopups.GetCustomControl("inputCustom1Name").focus(); 
				}
					function ModalPopupsCustom3Save() {
					var custom1Name = ModalPopups.GetCustomControl("inputCustom1EMail"); 
					if(custom1Name.value == "")
					{
						alert("Please submit a name to this form");
						custom2Name.focus();
					}
					else
					{
						alert("Your name is: " + custom1Name.value);
						ModalPopups.Close("iAlert2");
					}
				}
				
				function ModalPopupsCustom3Cancel() {
					//alert('You pressed Cancel');
					ModalPopups.Cancel("iAlert2");
				}
				function ModalPopupsConfirmNo() {
					//alert('You pressed No');
					ModalPopups.Cancel("idCustom2");
				}
				
function processCart(mode)
{
	document.frmcart.mode.value = mode;
	document.frmcart.submit();
}


function addtocart(mode,id)
{

	document.frmmerch.mode.value = mode;
	document.frmmerch.id.value = id;
	document.frmmerch.submit();
}


function hideTable(val)
{
	if(val==true)
	{
		document.getElementById('Ship_Address').style.display = "none";
	}
	else
	{
		document.getElementById('Ship_Address').style.display="";
		//document.frmsignup.sh_title.value="";
	}
}

function fillInfo(control,basefield,selectedfield)
{
	control.options.length = 0;
	flag = 0;
	for(i=0,j=0; i<fillArr.length; i++)
	{
		if(fillArr[i][0] == basefield)
		{
			if(selectedfield == fillArr[i][1])
			{
				control.options[j] = new Option(fillArr[i][1]+" "+fillArr[i][2]);
				control.options[j].value = fillArr[i][1];
				control.options[j].selected = true;
				flag = 1;
				
			}
			else
			{
				control.options[j] = new Option(fillArr[i][1]+" "+fillArr[i][2]);
				control.options[j].value = fillArr[i][1];
			}				
			j++;
		}
	}
}
var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printSpecial(){
	if(document.getElementById != null){
		var html = '<HTML>\n<HEAD>';
		if (document.getElementsByTagName != null){
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '\n</HE' + 'AD>\n<BODY style="background-color:#000000; color:#ffffff; font-size:11px;">\n';
		var printReadyElem = document.getElementById("printReady");
		if (printReadyElem != null){
			html += printReadyElem.innerHTML;
		}else{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint){
			printWin.print();
			printWin.close();
		}
	}else{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}				
