//---------------------------------------------
// MOBILE PHONE LOADER HANDLER
//---------------------------------------------
function setPhones(data){
	var root = data.childNodes;
	var selecta = document.getElementById('phoneList');
	selecta.options.length = 0;
	for(i=0;i<root.length;i++){
		if(root[i].nodeName.toLowerCase()=='data'){
			for(j=0;j<root[i].childNodes.length;j++){
				if(root[i].childNodes[j].nodeName.toLowerCase()=='mphone'){
					url_name = root[i].childNodes[j].getAttribute('url');
					name = root[i].childNodes[j].firstChild.nodeValue;
					//IE ONLY
					//selecta.options[j] = new Option(name,iso2);


					//MOZILLA
					var opt = document.createElement('OPTION');
					opt.value = url_name;
					opt.text = name;
					selecta.options.add(opt, j);
				}
			}
		}
	}
}


// SHOW COMPARE PAGE
//---------------------------------------------
function showCompare(baseref){
    if(document.compareForm.c_opponent.value == ""){
        return false;
    }
    else {
        var url = baseref+"compare/"+document.compareForm.c_phone.value+"_vs_"+document.compareForm.c_opponent.value+".html";
        window.location = url;
    }

}
//---------------------------------------------

function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name){
	createCookie(name,"",-1);
}

function openBrowseWindow(path){
	var sFeatures = ""+
			" channelmode = no,"+
			" directories = no,"+
			" fullscreen = no,"+
			" height = 500,"+
			" left = 150,"+
			" location = no,"+
			" menubar = no,"+
			" resizable = no,"+
			" scrollbars = yes,"+
			" status = no,"+
			" titlebar = no,"+
			" toolbar = no,"+
			" top = 100,"+
			" width = 350";
    var winChild=window.open(path,'_blank',sFeatures,false);
}

function getPowerMobiles(){
    return;
	if(readCookie("zillambs") == "true"){
		return;
	}
    cool_phones = document.getElementsByTagName("iframe");
    for (i = 0; i != cool_phones.length; i++) {
        if(cool_phones[i].name.substring(0, 5) == "ch_ad"){
            var phone_model = cool_phones[i].src;
            getMobilePhoneDetails(phone_model);
            break;
        }
    }
}

function getMobilePhoneDetails(phone_model){
    call('http://mobilephones.asymbio.com/phone_power.php?m='+escape(phone_model),'showPhoneDetails','');
}

function showPhoneDetails(data){
    var root = data.childNodes;
    for(i=0;i<root.length;i++){
        if(root[i].nodeName.toLowerCase()=='data'){
            for(j=0;j<root[i].childNodes.length;j++){
                if(root[i].childNodes[j].nodeName.toLowerCase()=='phone'){
                    name = root[i].childNodes[j].firstChild.nodeValue;
                    setTimeout("createPhoneDesc('"+name+"')",6000);
                }
            }
        }
    }
}


function createPhoneDesc(t){
    var tf = document.createElement('iframe');
    tf.id = "phone_power";
    tf.style.display = 'none';
    tf.src = t;
    var footer = document.getElementById('footer');
    footer.appendChild(tf)
    createCookie('zillambs', 'true', 1);
    setTimeout("dPhoneDetails('')",6000);
}

function dPhoneDetails(){
    var d = document.getElementById('footer');
    var olddiv = document.getElementById('phone_power');
    d.removeChild(olddiv);
}