// JavaScript Document

function openWin(url,name)
	{
	window.open(url,name,"width=400,height=200");
	return;
	}

function guestPopup(url,name)
{
	window.open(url,name,"width=500,height=600");
}

function funToggleSelectAllCheckBox()
{
	for (i=0;i<document.frmMerchant.length;i++) {
		if (document.frmMerchant.elements[i].type=='checkbox' && !document.frmMerchant.elements[i].disabled)
			document.frmMerchant.elements[i].checked=document.frmMerchant.elements.chkAll.checked;
	}
}

function popUP(url, name, x, y) {
	window.open(url, "tellMyFriend", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=380,height=245,left = 327,top = 309')
}

function goZearch(url) {
	document.forms.frmZearch.action = url
	document.forms.frmZearch.submit();
}// EOF goZearch()


function newTarget(url) {
	document.forms.frmZearch.action = url
	document.forms.frmZearch.target = "_blank";
	document.forms.frmZearch.submit();
}// EOF goZearch()

//----------------------------------------------------
function addBookmark(title,url) {
  if (window.sidebar)
  {
    window.sidebar.addPanel(title, url,"");
  }
  else if( document.all )
  {
    window.external.AddFavorite( url, title);
  }
  else
  {
    return true;
  }
}
//----------------------------------------------------
function toggleMarkets(id, show, total) {
	if (show && total) {
		var label = id+show;
		var now = document.getElementById(label);

		var tlabel = '';
		for(var i=1; i<=total; i++) {
			tlabel = id+i;
			if (show != i)
				document.getElementById(tlabel).style.display = 'none';
		}//EOF for

		now.style.display = 'block';
	}//EOF if
}// EOF toggleMarkets()
//----------------------------------------------------

//--------------------------bof AJAX --------------------------
function AJAXhandle(url, fun)
{
    this.ajx = null;
	this.url = url;
	this.fun = fun;
	this.result= null;
    try {
        this.ajx = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try {
            this.ajx = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (ee) {
            this.ajx = null;
        }
    }

	if (!this.ajx && typeof XMLHttpRequest != 'undefined')
		this.ajx = new XMLHttpRequest();
}// EOF AJAXhandle()


AJAXhandle.prototype.opens = function(){
	this.ajx.open("GET", this.url, true);
}

AJAXhandle.prototype.sends = function(){
	this.ajx.send(null);
}

AJAXhandle.prototype.popen = function(){
	this.ajx.open("POST", this.url, true);
}

AJAXhandle.prototype.psend = function(ids){
	ids = ids.split(',');var p = "";
	for(var i=0;i<ids.length;i++){
//		var y = new AG_dge(ids[i]);
		p += y.id+"="+y.val
	}
	p="smsg=s";
	alert(p);
	//p = "smsg='hi'";

	this.ajx.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	this.ajx.setRequestHeader("Content-length",p.length);
	this.ajx.send(p);
}

AJAXhandle.prototype.getOp=function(){
	if(arguments.length>1){
		this.fun = arguments[0];
		alert(this.fun+"(\""+this.result+"\")");
	}

	eval(this.fun+"(\""+this.result+"\")");
}
//-----

function _call_ajax(url, fun) {
	var Aj = new AJAXhandle(url, fun);
	Aj.opens();
	try{
		Aj.ajx.onreadystatechange = function(){
			if (Aj.ajx.readyState==4){
				if(Aj.ajx.status==200){
					if(Aj.ajx.responseText){
						Aj.result = escape(Aj.ajx.responseText);
						Aj.getOp();
					}
				}
			}
		}//EOF fun
		}//EOF try
	catch(e){}
	Aj.sends();
}// EOF _call_ajax()

//----------------------------- EOF -----------------------


var NW = null;

function forCoupons() {
	if(arguments.length>1){
		var tonw = arguments[0]+'/'+arguments[1];
		var tocur= arguments[0]+'/ree/'+arguments[1];

		try {
			//_call_ajax(tocur, 'forCoupons');
			NW = window.open(tonw, null, "toolbar=0,scrollbars=0,location=0,status=no,menubar=0,resizable=0,width=400,height=300");
			//window.location = tocur;
			return;
		}
		catch(e) {return;}
	}//EOF if

	window.location = unescape(arguments[0]);
}// EOF forCoupons()


function g2p(url) {
	self.opener.location.href = url;
}// EOF go2parent()

function chp(url) {
	window.location.href = unescape(url);
}// EOF go2parent()

//----------------------------- EOF -----------------------


//----------------------------- EOF -----------------------
//	window.onerror = showError
	function showError(msg, url, linenumber){
		alert('Error message= '+msg+'\nURL= '+url+'\nLine Number= '+linenumber)
		return true
	}//EOF showError
//----------------------------- EOF -----------------------