﻿function _makePrice(movieID){
    if(navigator.appName.indexOf('Microsoft') != -1 ){
        window["flashPriceOb" + movieID] = new Object();
    }
    var attr = { id:"flashPriceOb" + movieID, name:"flashPriceOb" + movieID};
    var params = {wmode:"transparent"};
    swfobject.embedSWF("shopPriceFlashText.swf?price=" + document.getElementById("flashPrice" + movieID).innerHTML, "flashPrice" + movieID, "187", "45", "9.0.0", false,false,params,attr);
}

function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("Opera") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}
   
function _cstDD_handleDropDown(s){
    var flashID = s.parentNode.id.split("£")[0].split("%")[1];
    try{
        getFlashMovie("flashPriceOb" + flashID).sendTextToFlash(s.title);
    }catch(err){
        document.getElementById("flashPrice" + flashID).innerHTML = s.title;
    }            
}

function buyItem(id){
    var price = "";
    var name = "";

    if(document.getElementById("flashPrice" + id)){
        sendRequest(document.getElementById("flashPrice" + id).innerHTML, id);
    }else{
        getFlashMovie("flashPriceOb" + id).getPrice(id);
    }
}

function sendRequest(price, id){
    var finalString = document.getElementById("shopT" + id).innerHTML;
    
    if(document.getElementById("cstDD%" + id + "£current")){
        finalString += "¬" + document.getElementById("cstDD%" + id + "£current").innerHTML;
    }else{
        finalString += "¬" + document.getElementById("noOptP" + id).innerHTML;
    }
    if(finalString.charAt(finalString.length-1) == " "){finalString = finalString.substr(0,finalString.length-1);}
    finalString += "¬" + price;
    document.getElementById(senderField).value = finalString;
    document.getElementById(senderButton).click();
}

function handleRemove(key){
    document.getElementById(senderField).value = "$-$" + key;
    document.getElementById(senderButton).click();
}
