function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }

function viewWin(page,title, height, width) {
  if (height==''){
	 height=500;
  }
  if (width==''){
		 width=500;
	  }
  
  var windowOptions = new Object();
  windowOptions.width = width;
  windowOptions.height = height;
  windowOptions.center = true;
  windowOptions.modal = true;
  windowOptions.resizeable = true;
  windowOptions.initshow = true;
  windowOptions.draggable = true;
  windowOptions.closeable = true;
  windowOptions.refreshOnShow = true;
  windowOptions.headerstyle = 'color:#FFFFFF; background-color:#958872; border:#958872; margin-left: -5px; margin-right: -5px;';
  windowOptions.bodystyle='padding:5px; font-family:Arial; font-size:12px; vertical-align: top; border:1px solid #958872';    
  ColdFusion.Window.create('siteWindow',title,page,windowOptions);
  ColdFusion.navigate(page,'siteWindow');
}

function switchid(open,close){
	document.getElementById(open).style.display = 'block';
	 document.getElementById(close).style.display = 'none';
}

function askOK(url){
	question = confirm("Are You Sure You Want to Delete This Address")
	if (question != "0"){
		window.open(url, "_self")
	}
}

function getObject(obj) {
	  var theObj;
	  if(document.all) {
	    if(typeof obj=="string") {
	      return document.all(obj);
	      return obj.style;
	    }
	  }
	  if(document.getElementById) {
	    if(typeof obj=="string") {
	      return document.getElementById(obj);
	    } else {
	      return obj.style;
	    }
	  }
	  return null;
	}

	//Contador de caracteres.
	function Contar(entrada,salida,texto,caracteres) {
	  var entradaObj=getObject(entrada);
	  var salidaObj=getObject(salida);
	  var longitud=caracteres - entradaObj.value.length;
	  if(longitud <= 0) {
	    longitud=0;
	    texto='<span class="disable"> '+texto+' </span>';
	    entradaObj.value=entradaObj.value.substr(0,caracteres);
	  }
	  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
	}
	
	var timeoutqv = 500;
	
	function askQuickview(location){
		$('#'+location).toggleClass("quickview");
		toggleDiv('qv-'+location);
		
	}
	function justClose(location){
		$('#'+location).toggleClass("quickview");
		toggleDiv('qv-'+location);
	}
	
	function closeQuickview(location){
		window.setTimeout("justClose('"+location+"')", timeout);
	}
	
	function showQuickview(item,session) {		  
		  var windowOptions = new Object();
		  windowOptions.width = 600;
		  windowOptions.height = 350;
		  windowOptions.center = true;
		  windowOptions.modal = true;
		  windowOptions.resizeable = true;
		  windowOptions.initshow = true;
		  windowOptions.draggable = true;
		  windowOptions.closeable = true;
		  windowOptions.refreshOnShow = true;
		  windowOptions.headerstyle = 'color:#FFFFFF; background-color:#958872; border:#958872; margin-left: -5px; margin-right: -5px;';
		  windowOptions.bodystyle='padding:5px; font-family:Arial; font-size:12px; vertical-align: top; border:1px solid #958872';
		  var url='../usrf.cfm?misc=quickView&item='+item+'&session='+session;
		  ColdFusion.Window.create('quickView','Quick View',url,windowOptions);
		  ColdFusion.navigate(url,'quickView');
		}
	
	function showShare(url,item) {		  
		  var windowOptions = new Object();
		  windowOptions.width = 500;
		  windowOptions.height = 250;
		  windowOptions.center = true;
		  windowOptions.modal = true;
		  windowOptions.resizeable = true;
		  windowOptions.initshow = true;
		  windowOptions.draggable = true;
		  windowOptions.closeable = true;
		  windowOptions.refreshOnShow = true;
		  windowOptions.headerstyle = 'color:#FFFFFF; background-color:#958872; border:#958872; margin-left: -5px; margin-right: -5px;';
		  windowOptions.bodystyle='padding:5px; font-family:Arial; font-size:12px; vertical-align: top; border:1px solid #958872';
		  var url='../usrf.cfm?misc=share&urlff='+url+'&item='+item;
		  ColdFusion.Window.create('share','Share',url,windowOptions);
		  ColdFusion.navigate(url,'share');
		}
	
	function closeWindow(windowName){
		ColdFusion.Window.hide(windowName);
		//ColdFusion.Window.destroy(windowName,true);
	}