
//-----------------------------------------------------------------------------//

function xmlRequest(url,id,pars,v){
var myAjax = new Ajax.Updater(id,url,{
method: "post",parameters: pars});
$(v).show();
$(id).hide();
responder = {	onComplete: function() {
					if(Ajax.activeRequestCount == 0){
						$(v).hide();
						$(id).show();
						Ajax.Responders.unregister(responder);
					}
				},
				onError: function(){
					$(v).hide();
					$(id).show();
					Ajax.Responders.unregister(responder);					
				}
			};
Ajax.Responders.register(responder);
}

function addMe(a,c){
	var items = decode(c);
	var ShowVal = function (t){
			if(t.responseText=='true'){
				alert("Logo Added to Cart");
			}else{
				alert(t.responseText);
			}
		}
	var options = {
				method : 'post',
				parameters : items,				
				onSuccess: ShowVal,
				onFailure: showAlert
		};
	var showAlert = function (t){
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	new Ajax.Request(decode(a),options);	
}

function checkData(){
var error="";
if($F('fname')=='' || $F('fname')==undefined || $F('fname')==null)
	error = error + "Empty First Name Field \n";
if($F('lname')=='' || $F('lname')==undefined || $F('lname')==null)
	error = error + "Empty Last Name Field \n";
if($F('add1')=='' || $F('add1')==undefined || $F('add1')==null)
	error = error + "Empty Address Field \n";
if($F('add2')=='' || $F('add2')==undefined || $F('add2')==null)
	error = error + "Empty City Field \n";
if($F('country')=='' || $F('country')==undefined || $F('country')==null)
	error = error + "Empty Country Field \n";
if($F('hphone')=='' || $F('hphone')==undefined || $F('hphone')==null)
	error = error + "Empty Daytime Field \n";
if($F('zcode')=='' || $F('zcode')==undefined || $F('zcode')==null)
	error = error + "Empty Zip Code Field \n";

 if($F('det')==1 || $F('det') != null){
 	  if($F('eadd')=='' || $F('eadd')==undefined || $F('eadd')==null){
		error = error + "Empty Email Address Field \n";
	  }else{
		var thisRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!thisRegExp.test($F('eadd')))
			error = error + "Email Address Field must contain a valid email address.\n";
	  }
	  if($F('pword')=='' || $F('pword')==undefined || $F('pword')==null)
		error = error + "Empty Password Field \n";	
	  if($F('cpword')=='' || $F('cpword')==undefined || $F('cpword')==null)
		error = error + "Empty Confirm Password Field \n";	
	  if($F('phint')=='' || $F('phint')==undefined || $F('phint')==null)
		error = error + "Empty Password Hint Field \n";
	  if($F('cpword').length>0 && $F('pword').length>0){
		if($F('pword') != $F('cpword'))
			error = error + "Password Not Match Field \n";	
	 }
  } 
	if(error != ''){
		alert(error);
	}else{
		$('checkoutinfo').submit();
	}
}

function makevisible(cur,which){
if(which)which = "#ADE4C2";else which = "";
	$("lestercabalona"+cur).style.background=which;
	$("ilestercabalona"+cur).style.background=which;
	$("iilestercabalona"+cur).style.background=which;
//if(which)which = "pointer";else which = "";
	// $("lestercabalona"+cur).style.cursor = which;
	// $("ilestercabalona"+cur).style.cursor=which;
	// $("iilestercabalona"+cur).style.cursor=which;
}

function cPane(id,url,DIVid){
	xmlRequest(decode(url),DIVid,"",id);
}

function revealModal(d, tt, r){
	//createDiv(t,w,h);	
    window.onscroll = function () {$(d).style.top = document.body.scrollTop;};
	if(r=='undefined' || r==null || r=='')
	Drag.init($("modalTop"), $("modal"));    
	$(d).style.display = "block";
    $(d).style.top = document.body.scrollTop;
	$('modalTitle').update(tt);
}

function hideModal(d){$(d).style.display = "none";$('modalTitle').update('');}

function login(u,n){
	$('modalContainer').style.width = '300px';
	$('modalPage').style.width = getWidth();
	$('modalPage').style.height = getheight();
	$('modal').style.top = "-300px";
	$('modal').style.left = (getWidth()/4);
	revealModal("modalPage", n);
	xmlRequest(decode(u),"popContent","","popLoading");
}

function popup(u,n){
	$('modalContainer').style.width = '520px';
	$('modalPage').style.width = getWidth();
	$('modalPage').style.height = getheight();
	$('modal').style.top = "-300px";
	$('modal').style.left = (getWidth()/5);
	revealModal("modalPage", n);
	xmlRequest(decode(u),"popContent","","popLoading");
}

function popupnotdrag(u,n){		
	$('modalContainer').style.width = '520px';
	$('modalPage').style.width = getWidth();
	$('modalPage').style.height = getheight();	
	$('modal').style.top = "-300px";
	$('modal').style.left = (getWidth()/5);	
	revealModal("modalPage", n, 1);
	xmlRequest(decode(u),"popContent","","popLoading");
}

function getWidth() {  
	var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;    
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;    
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;    
  }
	return myWidth;
}

function getheight() {  
	var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE    
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'    
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible    
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}
function rd(u){
	document.location.href=decode(u);
}

function toggleCheck(i){
	if (i.checked) {
		i.value = 1;
	} else {
		i.value = 0;
	}
}
