function processCart(mode)
{
	document.frmcart.mode.value = mode;
	document.frmcart.submit();
}

function addtocart(mode,id)
{
	qty=document.getElementById("qty"+id).value;
	if(qty!='')
	{
	document.frmmerch.mode.value = mode;
	document.frmmerch.id.value = id;
	document.frmmerch.qty.value=qty;
	document.frmmerch.submit();
	}
	else
	{
		 alert("Please enter quantity");
	}
}


function hideTable(val)
{
	if(val==true)
	{
		document.getElementById('Ship_Address').style.display = "none";
	}
	else
	{
		document.getElementById('Ship_Address').style.display="";
	}
}

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++;
		}
	}
}
function checkNumber(textBox)
{
	
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = textBox.value;
}

/*
Post comment form
*/
function ModalPopupsAlert(blogid,replyid,ResultStr) {
	ModalPopups.Custom("iAlert2",
		"Post Comment",
		"<form action='index.php?pg=postcomment' name='post_comment' method='post'>"+
		"<input type='hidden' name='blogid' value='"+blogid+"'>"+
		"<input type='hidden' name='replyid' value='"+replyid+"'>"+
		"<div style='padding:10px; font-size:12px; color:#666666; padding:5px 3px 5px 3px; background-color:#f5f5f5'>" + 
		"<table>" + 
		/*"<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;</td><td><input type='text' id='postedby' name='postedby' style='padding:10px; font-size:12px; color:#666666; padding:5px 3px 5px 3px; width:300px;'/></td></tr>" + */
		"<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comment&nbsp;&nbsp;</td><td><textarea id='comment' name='comment' style='padding:10px; font-size:12px; color:#666666; padding:5px 3px 5px 3px; width:300px;'></textarea></td></tr>" + 
		"<tr><td>" +
		"</td><td><input type='text' name='imageText' id='imageText' style='padding:10px; font-size:12px; color:#666666; padding:5px 3px 5px 3px; width:191px;'  />&nbsp;<img id='captchaImg' src='captcha.php?rqImg="+ResultStr+"' align='absbottom' alt='' />" +
		"<input type='hidden' name='captext' id='captext' value='"+ResultStr+"'/>&nbsp;<img src='images/refresh.jpg' align='absbottom'  alt='CAPTCHA' border='0' style='cursor:pointer;' onclick='javascript: newImage(\"1\");'/>&nbsp;</td></tr>" + 
		"</table>" +
		"</div>"+
		"</form>", 
		{
			width: 500,
			buttons: "ok,cancel",
			okButtonText: "SUBMIT",
			cancelButtonText: "CANCEL",
			onOk: "ModalPopupsCustomSave()",
			onCancel: "ModalPopupsCustomCancel()"
		}
	);
			
	//ModalPopups.GetCustomControl("inputCustom1Name").focus(); 
}
function ModalPopupsCustomSave() {
	var postedBy = ModalPopups.GetCustomControl("postedby");
	var comment = ModalPopups.GetCustomControl("comment");
	var captext = ModalPopups.GetCustomControl("captext").value; 
	var imageText = ModalPopups.GetCustomControl("imageText").value; 
	
	/*if(postedBy.value == "")
	{
		alert("Enter your name");
		postedBy.focus();
	}
	else */
	if(comment.value == "")
	{
		alert("Enter comment text");
		comment.focus();	
	}
	else if(captext!=imageText)
	{
		alert("Enter the Verification code exactly as shown in this image. (Case Sensitive)");
		captext.focus();
	}
	else
	{
		document.post_comment.submit();	
	}
}
				
function ModalPopupsCustomCancel() {
	//alert('You pressed Cancel');
	ModalPopups.Cancel("iAlert2");
}
function newImage(rqImg)
{
	//alert(textId);	
	if(rqImg==1)
	{
		rtext=randomString_blog();
		document.getElementById("captext").value=rtext;

		document.getElementById("captchaImg").src='captcha.php?rqImg='+rtext+'';
	}
	if(rqImg==2)
	{	
		rtext=randomString_blog();
		document.getElementById("rcaptext").value=rtext;
		document.getElementById("rcaptchaImg").src='captcha.php?rqImg='+rtext+'';
	}
}
function randomString_blog() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
function showCounties_scdt(str,flg)
{
	
if (str=="")
  {
  //document.getElementById("divTrack").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp1=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
	 
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {	//alert(xmlhttp1.responseText);	
		if(flg==1)
		{
			if(xmlhttp1.responseText!='')
			{
		document.getElementById("billing_county").style.display="";
		document.getElementById("billing_countysel").innerHTML=xmlhttp1.responseText;
			}
			else
			{
				document.getElementById("billing_county").style.display="none";
			}
		}
		else
		{
			 if(xmlhttp1.responseText!='')
			{
		document.getElementById("shipping_county").style.display="";
		document.getElementById("shipping_countysel").innerHTML=xmlhttp1.responseText;
			}
			else
			{
				document.getElementById("shipping_county").style.display="none";
			}
		}
	}
  }
xmlhttp1.open("GET","getcounty.php?state_id="+str+"&flg="+flg,true);
xmlhttp1.send();
}
		
	//ModalPopups.GetCustomControl("inputCustom1Name").focus(); 

