function addBookmarkForBrowser(tc,nm) {
	if (window.sidebar) { 
		window.sidebar.addPanel('{$domain} - ' + nm,'http://www.{$domain}/$indx?tc=' + tc,""); 
	} else if( document.all ) {
		window.external.AddFavorite('http://www.{$domain}/$indx?tc=' + tc, '{$domain} - ' + nm);
	} else if( window.opera && window.print ) {
		return true;
	}
}


function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


function restoreDefault(el) {
  if (el.value=="") el.value = el.defaultValue
}

function submitenter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13){
	   myfield.form.submit();
	   return false;
	}else
	   return true;
}

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.0
  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 && document.getElementById) x=document.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];}
}

buttonClicked=false;
function myCoupons(url) {
	if(document.coupons.agree.checked == false){ 
		alert('Please Agree to the Terms of Coupon Usage'); 
		return false;
	}else{
    	windowName = window.open(url,'Coupons','width=690,height=550,toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=no');
		windowName.focus();
		return true;
	}
}

function popWin(url){
		windowName = window.open (url, 'popsml', config='height=300,width=400, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
		windowName.focus();
}
function popWin2(url){
		windowName = window.open (url, 'popsml', config='height=530,width=400, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
		windowName.focus();
}
function popLargeWin(url){
		windowName = window.open (url, 'poplrg', config='height=650,width=800, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, directories=yes, status=yes');
		windowName.focus();
}

var ispromo = false;
var isforum = false;
function validateFields(theFields) {
// skip if promo code is sent
 if(!ispromo){
	 var fldArr  = theFields.split('|') ;
	 for (i =0; i < fldArr.length; i++) {
	   if(fldArr[i] == 'state'){
			if (document.getElementById('state').options[0].selected == true){
					alert('Please select a state');			
					return false;
			}
	   }else if(document.getElementById(fldArr[i]).value == ""){
		  alert(document.getElementById(fldArr[i]).name + ' cannot be empty.') ;
		  document.getElementById(fldArr[i]).focus() ;
		  return false ;
	   }
	 }
	 
	 if(document.forms[0].name=='registrationForm' && (document.getElementById('password').value != document.getElementById('cnfPassword').value)){
		 alert('Password and Confirm Password do not match') ;
			 document.getElementById('password').focus() ;
			 return false ;
	 }
	 if(document.forms[0].name=='registrationForm' && (document.getElementById('email').value != document.getElementById('cnfemail').value)){
		 alert('Email and Confirm Email do not match') ;
			 document.getElementById('email').focus() ;
			 return false ;
	 }
}
if(isforum){ 
	form_add2.style.display = "none";
	progress.style.display = "";
	setTimeout('document.images["wait"].src = "/images/wait.gif"', 200); 
}
 return true;
}


function skip()
{ 
document.forms[0].Make_Payment.focus();
//this.blur(); 
} 

function checkReview(){

var btn = document.forms[1].radRating;
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt < 0){ 
		alert ('Please Select a Rating: 1 to 5');
		return false;
	}
	
  if( document.forms[1].txtReview.value == "" ){
    alert ('Please Write a Review');
	return false;
	}
	
return true;
}

function checkPost(){
  if( document.forms[0].txtTopic.value == "" ){
    alert ('Subject Cannot be Blank');
	return false;
	}

  // CWS: Add check for email address
  var emailstr = document.forms[0].posterEmail.value;
  if(document.forms[0].u.value == "0" && emailstr == "")
  {
    alert ('Email address cannot be blank');
    return false;
  }
  if(document.forms[0].u.value == "0" && !((emailstr.indexOf(".") > 2) && (emailstr.indexOf("@") > 0)))
  {
    alert ('Email address must be in valid format');
    return false;
  }
  if(document.forms[0].u.value == "0")
  {
    alert('Your email address must be verified before your post is viewable to the community. ' +
    'You will receive an email at the address you have entered. Please check your email to ' +
    'confirm your address and complete the posting.');
    return true;
  }

return true;
}

function checkCal(){
  var btn = document.post.category;
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt < 0){ 
		alert ('Please Select a Category');
		return false;
	}

return true;
}

function disableForm(theform) {
  if(document.photoup.agree.checked == false){ 
		alert('Please Agree to the Photo Usage License Agreement'); 
		return false;
  }else{	
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var tempobj = theform.elements[i];
		if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
		tempobj.style.display = "none";
		}
	rules.style.display = "none";
	progress.style.display = "";
	setTimeout('document.images["wait"].src = "/images/wait.gif"', 200);
	}
   return true;
  }
}

function disableSubmit(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var tempobj = theform.elements[i];
		if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
		tempobj.disabled = true;
		}
	}
   return true;
}

function ask() {
	if( document.forms[0].indep.checked ) {
		askname.style.display = "";
		askname2.style.display = "";
	}else{
		askname.style.display = "none";
		askname2.style.display = "none";
	}
}

function ask2() {
	if( document.forms[0].pxstat.checked ) {
		pxask.style.display = "";
		pxask2.style.display = "";
	}else{
		pxask.style.display = "none";
		pxask2.style.display = "none";
	}
}

function showsubs(id) {
	switch (id){
		case 1: var cur = sub1.style.display;
 				if ( cur == "none" ){ sub1.style.display = "";
				}else{ sub1.style.display = "none"; }
				break;
		case 2: var cur = sub2.style.display;
 				if ( cur == "none" ){ sub2.style.display = "";
				}else{ sub2.style.display = "none"; }
				break;
		case 3: var cur = sub3.style.display;
 				if ( cur == "none" ){ sub3.style.display = "";
				}else{ sub3.style.display = "none"; }
				break;
		case 4: var cur = sub4.style.display;
 				if ( cur == "none" ){ sub4.style.display = "";
				}else{ sub4.style.display = "none"; }
				break;
	}
}

function showwait(){
	forma.style.display = "none";
	progress.style.display = "";
	setTimeout('document.images["wait"].src = "/images/wait.gif"', 200); 
	return true;
}

function showline() {
	show1.style.display = "";
	show2.style.display = "";
	show3.style.display = "";
}

function showcats() {
	show1.style.display = "";
	hide1.style.display = "none";
}

function zip2cq() {
	var cq0 = document.forms[0].quilt0.value;
	if (!cq0) {
		document.forms[0].quilt0.value = document.forms[0].zip.value;
	}
}

function CopyField(id) {
	var text1=document.getElementById(id);
	text1.focus();
	text1.select();
	therange=text1.createTextRange();
	therange.execCommand("Copy");
}
  
function Reload (frm) {
	var f = document.getElementById(frm);
	f.src = f.src + '?frm';
	return true;
}