function addfav(){
	if (document.all){window.external.addFavorite('http://www.sellcheapaiongold.com','sellcheapaiongold.com - Provide with cheapest Aion Kina');}
	else if (window.sidebar){window.sidebar.addPanel('sellcheapaiongold.com - Provide with cheapest aion kina and power leveling services', 'http://www.sellcheapaiongold.com', "");}
}

function chklogin(){with (document.getElementById('loginform')){
if (email.value == '' || !email.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
alert('Please input your email !');email.focus();return false;}
if (password.value == ''){alert('Please input your password !');password.focus();return false;}}}

function buy(id){
	var cur_id = document.getElementById("selcurrency").value;
	var oform = document.getElementById("listform");
	oform.cid.value = cur_id;oform.pid.value=id;
	oform.submit();
}
function roundAmount(n){
	var s = "" + Math.round(n*100)/100;
	var i = s.indexOf('.');
	if (i < 0) return s + ".00";
	var t=s.substring(0,i+1) + s.substring(i+1,i+3);
	if(i + 2 == s.length) t += "0";
	return  t;
}
function setcurrency(selobj){
	var ptable = document.getElementById("tbl");
	var rows_count = ptable.rows.length;
	var currency_id = selobj.value;
	var exchangeRate;
	if (currency_id==1){currency_code='USD';exchangeRate=1;}
	if (currency_id==2){currency_code='EUR';exchangeRate=rateEur;}
	if (currency_id==3){currency_code='GBP';exchangeRate=rateGbp;}
	for(i=1;i<rows_count;i++){
		var proprice = arrPrice[i-1];
		proprice = proprice * exchangeRate;
		proprice = roundAmount(proprice);
		ptable.rows[i].cells[1].innerHTML = proprice + '  ' + currency_code;
	}
}
var arrPrice = new Array();
function direct (selobj){
	var dirpage = selobj.value;
	window.location=dirpage;
}

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

function prepdt(){
	var ptable = document.getElementById("tbl");
	if (ptable==null){return}
	var rows_count = ptable.rows.length;
	for(i=1;i<rows_count;i++){
		var priceUSD = parseFloat(ptable.rows[i].cells[1].innerHTML);
		priceUSD = roundAmount(priceUSD);
		arrPrice.push(priceUSD);
	}
	setcurrency(document.getElementById("selcurrency"));
}

function $(id) {
	return document.getElementById(id);
}

function appendToSelect(select, value, content) {
	var opt = document.createElement('option');
	opt.value = value;
	opt.text = content;
	select.options.add(opt);
}

function clearOptionList(obj) {
	while (obj.options.length > 0) {
		obj.remove(0);
	}
}

function resetSelect(obj) {
	var optv = obj.options[0].value;
	var optc = obj.options[0].text;
	clearOptionList(obj);
	appendToSelect(obj,optv,optc);
}

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

addLoadEvent(prepdt);
