function newWin(url, contentWidth, contentHeight, params, target, returnVoid)
{
	var winWidth = contentWidth + 0;
	var winHeight = contentHeight + 0;

	if(params)
		params = ','+params;
	else
		params = '';

	posX = screen.width / 2 - (winWidth + 10) / 2;
	posY = screen.height / 2 - (winHeight + 10) / 2;

	var win = window.open(url, target ? target : '_blank', 'width='+winWidth+',height='+winHeight+params);
	win.moveTo(posX, posY);

	if(!returnVoid)
		return false;
}

function DecodeEmail(email, label)
{
   var AntiSpamChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_=?%';

	var decodedData = {'email':'', 'label':''};
	var encodedData = {'email':email, 'label':label};

	for(key in encodedData)
	{
		var k = 0;
		var Char = null;

		var value = encodedData[key];
		if(!value)
		   continue;

		for(i = 0; i < value.length; i++)
		{
			Char = value.charAt(i);
			CharIdx = AntiSpamChars.indexOf(Char);

			k = k > 6 ? 0 : k;

			switch(k)
			{
				case 0: CharIdx -= AntiSpamChars.indexOf('M'); break;
				case 1: CharIdx -= AntiSpamChars.indexOf('a'); break;
				case 2: CharIdx -= AntiSpamChars.indexOf('r'); break;
				case 3: CharIdx -= AntiSpamChars.indexOf('t'); break;
				case 4: CharIdx -= AntiSpamChars.indexOf('h'); break;
				case 5: CharIdx -= AntiSpamChars.indexOf('a'); break;
				case 6: CharIdx -= AntiSpamChars.indexOf('s'); break;
			}

			k++;

			CharIdx = CharIdx < 0 ? AntiSpamChars.length+CharIdx : CharIdx;

			decodedData[key] += AntiSpamChars.charAt(CharIdx);
		}
		decodedData[key] = decodeURIComponent(decodedData[key]);
	}

	document.write('<a href="mailto:'+decodedData['email']+'">'+decodedData['label']+'</a>');
}

function rgb2hex(rgb)
{
	var dec2hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'];
	
	var hex = '#';
	var tmp;
	
	if(rgb[0] > 255 || rgb[1] > 255 || rgb[2] > 255)
	   return null;

	for(i = 0; i < 3; i++)
	{
 	   tmp = dec2hex[Math.floor(rgb[i] / 16)].toString();
	   tmp += dec2hex[rgb[i] % 16].toString();
		hex += tmp;
	}
	
	return hex;
}

function GetCookie(name)
{
	var value = null;
	var cookies = document.cookie;

	cookies = cookies.split(/; ?/);
	for(id in cookies)
	{
		var pair = cookies[id].split(/=/);
      if(pair[0] == name)
		   return pair[1];
	}
	
	return null;
}

function CheckValidCount(inp)
{
   if(inp.value.match(/[^0-9]/g))
      inp.value = inp.value.replace(/[^0-9]/g, '');
      
   if(inp.value == 0 && inp.value.length)
      inp.value = 1;
}

// ============================================================== //
// AJAX                                                           //
// ============================================================== //
var xmlHttp;

Ajax = {

	'noAjaxSupport' : false,

	'init' : function()
	{
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					this.noAjaxSupport = true;
				}
			}
		}
	},

	'sendRequest' : function(url, returnResult)
	{
		if (xmlHttp.readyState != 0) xmlHttp.abort();

      xmlHttp.open ('GET', url, true);
      xmlHttp.onreadystatechange = function()
		{
      	if(xmlHttp.readyState == 4 && Ajax.isSuccess() && xmlHttp.responseText)
			{
			   if(returnResult)
			   {
				   return xmlHttp.responseText;
				}
				else
				{
					eval(xmlHttp.responseText);
				}
        	}
      }
   	xmlHttp.send(null);
	},
	
	'postRequest' : {

		'data' : '',

		'prepare' : function(url, data)
		{
		   if (xmlHttp.readyState != 0) xmlHttp.abort();
		   
		   xmlHttp.open ('POST', url, true);
		   xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		   
         xmlHttp.onreadystatechange = function()
			{
      		if(xmlHttp.readyState == 4 && xmlHttp.responseText)
				{
					eval(xmlHttp.responseText);
        		}
      	}
      	this.data = data;
		},
		
		'send' : function()
		{
			xmlHttp.send(this.data);
		}
	},
	
	'isSuccess' : function()
	{
		try {
		   return !xmlHttp.status && locat8ion.protocol == 'file:' ||
		      (xmlHttp.status >= 200 && xmlHttp.status < 300) ||
		         xmlHttp.status == 304 ||
		            navigator.userAgent.indexOf('Safari') >= 0 && typeof xmlHttp.status == 'undefined';
		} catch(e) {}

		return false;
	}
}
// ============================================================== //



