
function openpopup(url,popup_name,height,width,other_properties)
{var left=parseInt((screen.width-350)/2);var top=parseInt((screen.height-300)/2)
var win_options='height=390,width=350,resizable=yes,'
+'scrollbars=yes,left='+left+',top='+top;window.open(url,popup_name,win_options);}
function checkDate(date_value)
{var val_chk_dt=date_value.split("/");new_date=new Date(val_chk_dt[2],val_chk_dt[1]-1,val_chk_dt[0],00,00,00);if(new_date.getFullYear()!=val_chk_dt[2]||new_date.getDate()!=val_chk_dt[0]||new_date.getMonth()!=val_chk_dt[1]-1){alert("Please enter valid date in DD/MM/YYYY format!");return false;}
return true;}
function doTooltip(e,msg){if(typeof Tooltip=="undefined"||!Tooltip.ready){return;}
Tooltip.show(e,msg);}
function hideTip(){if(typeof Tooltip=="undefined"||!Tooltip.ready)return;Tooltip.hide();}
function IsInt(sText)
{var ValidChars="0123456789";var IsInt=true;var Char;var sText1=sText.value;for(i=0;i<sText1.length&&IsInt==true;i++)
{Char=sText1.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsInt=false;}}
return IsInt;}
function validateEmail(email)
{if(email.length<=0)
{return true;}
var splitted=email.match("^(.+)@(.+)$");if(splitted==null)return false;if(splitted[1]!=null)
{var regexp_user=/^\"?[\w-_\.]*\"?$/;if(splitted[1].match(regexp_user)==null)return false;}
if(splitted[2]!=null)
{var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(splitted[2].match(regexp_domain)==null)
{var regexp_ip=/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(splitted[2].match(regexp_ip)==null)return false;}
return true;}
return false;}
function checkprod(Obj,msg){var ValidChars="0123456789";var IsInt=true;var Char;var sText1=Obj.value;if(sText1=='0')
{alert("Please enter valid quantity!");Obj.focus();IsInt=false;return false;}
else if(removeLeadingAndTrailingChar(sText1,' ')=='')
{alert("Please enter quantity!");Obj.focus();IsInt=false;return false;}
for(i=0;i<sText1.length&&IsInt==true;i++)
{Char=sText1.charAt(i);if(ValidChars.indexOf(Char)==-1)
{alert(msg);Obj.focus();IsInt=false;return false;}}
return true;}
function removeLeadingAndTrailingChar(inputString,removeChar)
{var returnString=inputString;if(removeChar.length)
{while(''+returnString.charAt(0)==removeChar)
{returnString=returnString.substring(1,returnString.length);}
while(''+returnString.charAt(returnString.length-1)==removeChar)
{returnString=returnString.substring(0,returnString.length-1);}}
return returnString;}
function showhidetab(spanid)
{var span_id=document.getElementById(spanid);if(span_id.style.display!=''){span_id.style.display='';}else{span_id.style.display='none';}}
function ChangeClass(spanid,type)
{if(type=='id')
span_id=document.getElementById(spanid);else
span_id=spanid;if(span_id.className=='leftsubnavhadericonbg'){span_id.className='leftsubnavhadericonbg1';}else{span_id.className='leftsubnavhadericonbg';}}
function newsletter_check()
{if(document.frm_nl.news_email.value=='')
{alert('Please enter email address!');document.frm_nl.news_email.focus();return false;}
else if(document.frm_nl.news_email.value!='')
{if(!validateEmail(document.frm_nl.news_email.value))
{alert('Please enter valid email address.');document.frm_nl.news_email.focus();return false;}}
return true;}
function ChkNLSignUp()
{if(document.getElementById('nl_email').value=='')
{document.getElementById('nl_err_msg').style.display='block';return false;}
else if(!validateEmail(document.getElementById('nl_email').value))
{document.getElementById('nl_err_msg').style.display='block';return false;}
document.frmnl.submit();return true;}
function EnableNLEmail()
{document.getElementById('email').disabled=false;}
function UpdateHidEmail()
{document.getElementById('hid_email').value=document.getElementById('email').value;}
function login_check()
{if(document.frm_login.email.value=='')
{alert('Please enter email address!');document.frm_login.email.focus();return false;}
else if(document.frm_login.email.value!='')
{if(!validateEmail(document.frm_login.email.value))
{alert('Please enter valid email address. ');document.frm_login.email.focus();return false;}}
if(document.frm_login.password.value=='')
{alert('Please type your password ');document.frm_login.password.focus();return false;}
return true;}
function validateEmail(email)
{var splitted=email.match("^(.+)@(.+)$");if(splitted==null)return false;if(splitted[1]!=null)
{var regexp_user=/^\"?[\w-_\.]*\"?$/;if(splitted[1].match(regexp_user)==null)return false;}
if(splitted[2]!=null)
{var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(splitted[2].match(regexp_domain)==null)
{var regexp_ip=/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(splitted[2].match(regexp_ip)==null)return false;}
return true;}
return false;}
function checksearch()
{var obj=document.getElementById('searchtxt');var txt=obj.value;if(txt==''||txt=='Search')
{alert('Please enter keyword to search ');obj.focus();return false;}
else
{window.location.href="/search.php?searchtxt="+txt;}
return true;}
function simplePreload()
{var args=simplePreload.arguments;document.imageArray=new Array(args.length);for(var i=0;i<args.length;i++)
{document.imageArray[i]=new Image;document.imageArray[i].src=args[i];}}
function addToBacket2()
{if(isNaN(document.getElementById('qty').value))
document.getElementById('qty').value=1;var count=document.frmprod2.elements.length;for(i=1;i<count;i++)
{if(document.frmprod2.elements[i].id=="attr")
{if(document.frmprod2.elements[i][document.frmprod2.elements[i].selectedIndex].value=="")
{alert("Please complete all fields before continuing to cart")
document.frmprod2.elements[i].focus();return false;}}}
pststr='';for(i=1;i<count;i++)
{if(document.frmprod2.elements[i].id=="attr")
{if(document.frmprod2.elements[i][document.frmprod2.elements[i].selectedIndex].value!="")
{pststr+="&"+document.frmprod2.elements[i].name+"="+document.frmprod2.elements[i][document.frmprod2.elements[i].selectedIndex].value;}}}
var poststr="prod_id="+encodeURI(document.getElementById("prod_id_attrib").value)+"&package_id="+encodeURI(document.getElementById("package_id2").value)+"&posted=true"+"&qty="+document.getElementById('qty').value+pststr;makePOSTRequest('product_attrib_pop.php',poststr,'p_attrib');}
function br2nl($text){return $text.replace(/\<br(\s*\/|)\>/g,"\r\n");}
function get(obj)
{cnt=document.getElementById('cnt').value;pststr="";for(i=1;i<=cnt;i++)
{ans=document.getElementById('pollcnt'+i);if(ans.checked)
{pststr+="&poll_ans[]="+ans.value;}}
var poststr="poll_id="+encodeURI(document.getElementById("poll_id").value)+"&poll="+encodeURI(document.getElementById("poll").value+pststr);makePOSTRequest('poll.php',poststr,'myspan');}

function get(obj) 
{
	cnt = document.getElementById('cnt').value;
	pststr = "";
	for(i=1;i<=cnt;i++)
	{
		ans = document.getElementById('pollcnt'+i);
		if(ans.checked)
		{
			pststr += "&poll_ans[]="+ans.value;
		}
	}

var poststr = "poll_id=" + encodeURI( document.getElementById("poll_id").value ) +
"&poll=" + encodeURI( document.getElementById("poll").value + pststr);

makePOSTRequest('poll.php', poststr,'myspan');
}
