/*
 * Cookie støff
 */
 
function createCookie(name, value, days) {
    var expires = '';
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = '; expires=' + date.toGMTString();
    }
    document.cookie = name + '=' + value + expires + '; path=/';
}
 
function readCookie(name) {
    var cookieCrumbs = document.cookie.split(';');
    var nameToFind = name + '=';
    for (var i = 0; i < cookieCrumbs.length; i++) {
        var crumb = cookieCrumbs[i];
        while (crumb.charAt(0) == ' ') {
            crumb = crumb.substring(1, crumb.length); /* delete spaces */
        }
        if (crumb.indexOf(nameToFind) == 0) {
            return crumb.substring(nameToFind.length, crumb.length);
        }
    }
    return null;
}
 
function eraseCookie(name) {
    createCookie(name, '', -1);
}

/*
 * other stuff
 */

function getHandsetValues(handsetBrand) {
	GetContent('handsetDiv','/pages/handsetPicker.ftl?brand='+handsetBrand, false);
	
}

function setHandset(handsetString) {
	eraseCookie("handsetType");
	createCookie("handsetType", handsetString, 365);
	document.handsetForm.submit();
}

function getHandset() {
	var selectedHandset = readCookie("handsetType");
	//alert(selectedHandset);
	return selectedHandset;
}

function dostuff() {
	var handset = getHandset();
	GetContent('handSetSetterDiv','/pages/handsetSetter.ftl?handset='+handset, false);
}

function stopSubscription(subscriptionId){
	GetContent('stopStatusDiv', '/pages/ajax/CancelSubscription.ftl?subscriptionId='+subscriptionId, false);
}

function requestPassword(phoneNumber, buttonId){
	GetContent('requestPasswordDiv','/pages/ajax/requestPass.ftl?phoneNumber='+phoneNumber, false);
	var button = document.getElementById(buttonId);
	button.style.visibility = "hidden";
}
function objSWF(obj,param,width,height){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id=""><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+obj+'?'+param+'" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="transparent" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+obj+'?'+param+'" quality="high" menu="false" bgcolor="#ffffff" width="'+width+'" height="'+height+'" allowScriptAccess="sameDomain" name="" wmode="transparent" scale="noscale" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}
