function PAGEPOPUP(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=950,height=600');");
}

function DEMOPOPUP(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=780,height=500');");
}

function MAILPOPUP(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'status=0,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=890,height=750');");
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=320');");
}

function infopopUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=340');");
}

function make_includes( sb )
{
  sb.value = sb.value.replace( /\s*,\s*/g, '|' );
}
function SmallpopUp(URL) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
}
function TaskpopUp(URL) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=650');");
}

//function submit_search( evt, tb )
//{
// if( evt.keyCode == 13 )
// {
//	window.location="http://www.etelos.com/store/search_results.espx?storetab=on&searchval="+tb;
// }
//  evt.cancelBubble = true;
//}

function screenpop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=350');");
}

function printpage()
{
window.print()
}

function checkMaxLength(cthis) 
{
	var maxLength = cthis.getAttribute('maxlength');
	var curvalue = cthis.value
	var currentLength = curvalue.length;
	if (currentLength > maxLength)
	{
		alert("Input exceeds allowed length.");
		var newval = curvalue.substring(0, maxLength);
		cthis.value = newval;
	}
}

function parseUri (str) {
	var	o	= parseUri.options,
		m	= o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri	= {},
		i	= 14;
	while(i--) uri[o.key[i]] = m[i] || "";
	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});
	return uri;
};
parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function marketplaceHitCount(mid)
{
	var uid = '';
	m = /eas_uuid=([a-z0-9]{32})/.exec(document.cookie);
	if(m) uid = m[1];
	//http://reports.etelos.com/marketplace_hit.php?mid=XXX&uid=XXX
	data = "mid=" + mid + "&uid=" + uid;
	new Ajax.Request('http://reports.etelos.com/marketplace_hit.php?' + data, {
		method:'get',
		onSuccess:function(xhr,meta){}
	});
}
