// JavaScript Document
// Include this script in every page for future use of javascripts
function btnHover(loc,cls){
	// use: onmouseover="hov(this,'btn btnhov')" onmouseout="hov(this,'btn')
	// use2: onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'
   if(loc.className) loc.className=cls;
}

var newwindow;
function showPop(url,w,h)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	if(w < 100) w = 540;
	if(h < 100) h = 500;
	if(w == 0) w = 540;
	url = "http://www.yahaggle.com/" + url;
	newwindow=window.open(url,'yahagglewin','width='+w+',height='+h+',left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

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;
}

//MM_changeProp('test1','','innerHTML','testeafdafa','DIV')
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//write to div/layer
//use: WriteLayer(divID,null,text)
function WriteLayer(ID,parentID,text) {
if (document.layers) {
var oLayer;
if(parentID){
oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
}else{
oLayer = document.layers[ID].document;
}
oLayer.open();
oLayer.write(text);
oLayer.close();
}
else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
document.getElementById(ID).innerHTML = text;
}
else if (document.all) document.all[ID].innerHTML = text;
}

function cent(amount) {
// returns the amount in the .99 format 
    //amount -= 0;
    amount = (Math.round(amount*100))/100;
    return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function jumpTo(URL_List){
  var URL = URL_List.options[URL_List.selectedIndex].value;
  if (URL!=""){window.location.href = URL;}
}

function goto(URL){
	window.location.href = URL;
}

function getCompareList(formName) { 

	var theform = eval("document."+formName);
	theform.cList.value = "";
	var total = 0;

	if (theform.compList) {
		//alert('1 or more');
		if (theform.compList.length) {
			//alert('> 1');
			var L = theform.compList.length;
			for(var i=0; i < L; i++){
				if(theform.compList[i].checked) {
					total = total + 1;
				}
			}
		} else {
			if(theform.compList.checked){
				total = 1;
			}
		}
	} 

/*
	if(typeof(theform.compList) != "undefined") {		
		for(var i=0; i < theform.compList.length; i++){
			if(theform.compList[i].checked) {
				total = total + 1;
			}
		}
	}
*/	
	if(total > 0) {
		//alert(total);
		return true;
	} else {
		return false;
	}	
} 

function checkAll(formObj) {
	if(formObj.check.checked) {
		selectAll(formObj, 0);
		formObj.check.checked = true;
	} else {
		selectAll(formObj, 1);
		formObj.check.checked = false;
	}

}

function selectAll(formObj, isInverse) 
{
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      { 
         if(isInverse)
            fldObj.checked = (fldObj.checked) ? false : true;
         else fldObj.checked = true; 
       }
   }
}

function setPicturesPref(action,URL)
{
	//Use: onClick="setPicturesPref(<%=action%>,'<%=request.QueryString%>')"
	//alert(action + " - " + "search.asp?"+ URL);
	var args = URL.split('&') ;// parse out name/value pairs separated via &
	var URL2 = "";
	var found = false;
	// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var pair = args[i].split('=');
		if(pair[0] == "noshowpic") {
			pair[1] = action;
			args[i] = pair[0] + "=" + pair[1];
			found = true;
			break;
			//alert(args[i]);
		}
	}
	
	URL2 = args.join("&");
	if (found==false) {URL2 = URL2 + "&noshowpic=" + action;}
	window.location.href = "search.asp?"+URL2;
}

function setView(action,URL)
{
	//view=list:grid
	var args = URL.split('&') ;// parse out name/value pairs separated via &
	var URL2 = "";
	var found = false;
	// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var pair = args[i].split('=');
		if(pair[0] == "viewgrid") {
			pair[1] = action;
			args[i] = pair[0] + "=" + pair[1];
			found = true;
			//alert(args[i]);
			break;
			
		}
	}
	
	URL2 = args.join("&");
	if (found==false) {URL2 = URL2 + "&viewgrid=" + action;}
	window.location.href = "search.asp?"+URL2;
}

//play video function
function playMedia(m){
	var ww = 410;
	var wh = 350;
	m = '1a]R[Blogger_2e9f0ab7944ba136';
	eval("window.open('http://www.yahaggle.com/playMedia.asp?m=" + m + "','_Media','status=0,scrollbars=1,directories=0,toolbar=0,location=0,menubar=0,resizable=1,width=" + ww + ",height=" + wh + ",screenx=2,screeny=2')");
	return false;
}