function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+"="+escape( value ) +
( ( expires ) ? ";expires="+expires_date.toGMTString() : "" )

+ //expires.toGMTString()
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



var addEvent;
if (document.addEventListener) {
	addEvent = function(element, type, handler) {
		element.addEventListener(type, handler, null);
	}
}
else if (document.attachEvent) {
	addEvent = function(element, type, handler) {
	element.attachEvent("on" + type, handler);
	}
}
else {
	addEvent = new Function; // not supported
}
/*
function preparePage() {
	if(document.getElementById){
		document.getElementById("statepicker").className="hidden";
		
		addEvent (document.getElementById("choosestate"), 'click', showhide, false) ;
		addEvent (document.getElementById("selectallstates"), 'click', checkall, false) ;
		addEvent (document.getElementById("selectallregions"), 'click', checkall, false) ;
	}
}


function showhide() {
	var myEl = document.getElementById('statepicker') ;
	divclass = document.getElementById('statepicker').className ;
	if (divclass == 'hidden') {
		myEl.className="" ;
		return false
	}
	else {
		myEl.className="hidden"
		return false
	}
}

function checkall(e){
	myEl = getTarget(e) ;
	if (!myEl) return ;
	myGroup = climbDOM(myEl,'div').getElementsByTagName("input") ;
	for (i in myGroup) {
		if (myGroup[i] !== myEl) {
			myGroup[i].checked = myEl.checked ;
		}
	}
}

function checknone(){
	document.getElementById("statepicker").getElementsByTagName("input");
	for (i in x) {
		x[i].checked=false;
	}
}

function getTarget(e) {
	if (window.event && window.event.srcElement)
		return window.event.srcElement ;
	if (e && e.target)
		return e.target ;
	if (!e)
		return false ;
}

function climbDOM(e, tag_type) {
	while (e.nodeName.toLowerCase() != tag_type && e.nodeName.toLowerCase() != 'html') e = e.parentNode ;
	return (e.nodeName.toLowerCase() == 'html') ? null : e ;
}

addEvent(window, 'load', preparePage, false) ;
*/



function sjsc(){
   var xmlhttp=false;
   try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} 
   catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) {xmlhttp = false;}}
   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {xmlhttp = new XMLHttpRequest();}
   
   if(xmlhttp!==false)
      setCookie("aJS","yes",7,"/","liveauctioneers.com",false);
   setCookie("JS","yes",7,"/","liveauctioneers.com",false);
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);win.focus()}

function alertDropDownChangeF(t,query,aid,qid){
   if(t.value=='edit'||t.value=='delete'){
      $('form-'+t.id).submit();
   }else if(t.value=='preview'){
      window.location='/alert?q='+query+'&display=preview';
   }else if(t.value=='sendnow'){
      window.location='/alert?alert='+aid+'&qid='+qid+'&display=realmail';
   }
   
}
var sph_id=0;
function rsic(){// Register Search Item Click
   if(sph_id>0)
      setCookie("icf",sph_id,7,"/","liveauctioneers.com",false);
}






function saveDoc(t,docid){
//alert("test");
//	urchinTracker('/item-save/'+docid);
	new Ajax.Request('/js/load/item/save/'+docid+'?'+(new Date()).getTime(),
                        {method:'get',
                         onSuccess: function(transport){
                            
                            var response = transport.responseText || "";
                            //alert("response: "+response);
                            response=response.split(" ");
                            
                            if(response[0] == 'saved'){
                            	$('save_'+response[1]).innerHTML='<span>unsave</span>';
                            	$('save_'+response[1]).addClassName('unsave');
                            	new Effect.Highlight('itemnumber_'+response[1]);
                            	new Effect.Pulsate('save_'+response[1]);
                            }else if(response[0] == 'unsaved'){
                            	new Effect.Fade('save_'+response[1],{ duration: 2});
                            	new Effect.Appear('save_'+response[1],{ queue: 'end'});
                              $('save_'+response[1]).innerHTML='<span>save</span>';
                            	$('save_'+response[1]).removeClassName('unsave');
                            	
                            }
                            
                            
                            
                         }
                      });
   
}

function centerGalleryImages(t){
	var w=t.width;
	var h=t.height;
	/*
	if(w >= 160 && h < 180){
		t.width=160;
		t.height=h*(160/w);
	}else if(w < 160 && h >= 180){
		t.width=w*(180/h);
		t.height=180;
	}else if(w >= 160 && h >= 180){
		h_p=h/180;
		w_p=w/160;
		if(h_p>w_p){
			t.width=w*(180/h);
			t.height=180;
		}else if(h_p>w_p){
			t.width=160;
			t.height=h*(160/w);
		}else{
			t.width=w*(180/h);
			t.height=h*(160/w);
		}
	}*/
	//alert("width:"+t.width+" height:"+t.height);
	
	var mt=(200-t.height)/2;
	t.style.marginTop=mt+"px";
}