
var VAT_RATE            = 1.175
var SWREG_SHOP          = 50432
var SWREG_SERVER        = "http://gbp.swreg.org/cgi-bin/s.cgi?"
var SWREG_SHOP_US       = 50432
var SWREG_SERVER_US     = "http://gbp.swreg.org/cgi-bin/s.cgi?"

var idInc = 0;

products = {

        "50432DR2":{"name":"DigiRostrum","price": 55, "dollar": 110, "type":"Licence only", "version":"0", "code":"50432DR2"},
        "50432DR2CD":{"name":"DigiRostrum","price": 63, "dollar": 126, "type":"Licence & CD", "version":"0", "code":"50432DR2CD"},
        "50432DR2_U":{"name":"DigiRostrum","price": 20, "dollar": 40, "type":"Upgrade", "version":"1", "code":"50432DR2"},
        "50432DR2CD_U":{"name":"DigiRostrum","price": 28, "dollar": 56, "type":"Upgrade & CD", "version":"1", "code":"50432DR2CD"},
        "50432DV1":{"name":"DVACE","price": 18, "dollar": 36, "type":"Licence only", "version":"0", "code":"5043250432DV1"},
        "50432DV1CD":{"name":"DVACE","price": 26, "dollar": 52, "type":"Licence & CD", "version":"0", "code":"50432DV1CD"}
}

function setAdSenseColours()
{
    google_color_border = "AEB3B7";
    google_color_bg     = "FFFFFF";
    google_color_link   = "9966CC";
    google_color_text   = "000000";
    google_color_url    = "9966CC";
}

function setAdSenseVars_side()
{
    setAdSenseColours()
    google_ad_client = "pub-9477852344887985";
    google_ad_width = 120;
    google_ad_height = 240;
    google_ad_format = "120x240_as";
    google_ad_type = "text_image";
    google_ad_channel = "";
}

function setAdSenseVars_bottom()
{
    setAdSenseColours()
    google_ad_client = "pub-9477852344887985";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_type = "text_image";
    google_ad_channel = "";
}

function buildFooter()
{
    eDIV = document.createElement("div");
    eDIV.setAttribute("id","myDiv");
    addText(eDIV, "Copyright© 2007 Lumidium Ltd. All rights reserved.")
    addLineReturn(eDIV);
    addLink(eDIV, "privacy.htm", "privacy policy")
    addText(eDIV, "|")
    addLink(eDIV, "terms.htm", "terms and conditions")
    document.getElementById("bottom").appendChild(eDIV);
}



function buildHeader()
{   
    eDIV = document.createElement("div");
    eDIV.setAttribute("id","myDiv");
    addImage(eDIV, "nudgeleft", "images/lumidium.gif", "", "");
    addLineReturn(eDIV)
    eImage = document.createElement("img");
    eImage.setAttribute("src","images/line.gif");
    eImage.setAttribute("width","830");
    eDIV.appendChild(eImage);
    addLineReturn(eDIV);
    addMenuItem(eDIV, "nudgeleft", "index.html", "images/home.gif", "images/homeOver.gif", "homeImage");
    addMenuItem(eDIV, "", "support.html", "images/support.gif", "images/supportOver.gif", "supportImage");
    addMenuItem(eDIV, "", "contacts.html", "images/contacts.gif", "images/contactsOver.gif", "scontactsImage");
    addImage(eDIV, "", "images/space2.gif", "510", "20");
    addMenuItem(eDIV, "", "digirostrum.html", "images/drOffVSmall.gif", "images/mouzOnVSmall.gif", "drImage");
    addImage(eDIV, "", "images/space2.gif", "20", "20");
    addMenuItem(eDIV, "", "dvace.html", "images/dvaceOffVSmall.gif", "images/dvaceOnVSmall.gif", "dvImage");
    addImage(eDIV, "", "images/space2.gif", "20", "20");
    addMenuItem(eDIV, "", "mouz.html", "images/mouzOffVSmall.gif", "images/mouzOnVSmall.gif", "moImage");

    
    // append your newly created DIV element to an already existing element.
    document.getElementById("header").appendChild(eDIV);
    
 
}

function addLink(obj, href, text)
{
    eAnchor = document.createElement("a");
    eAnchor.setAttribute("href",href);
    eAnchor.appendChild(document.createTextNode(text));
    obj.appendChild(eAnchor);
}

function addText(obj, text)
{
    obj.appendChild(document.createTextNode(text));
}

function addImage(obj, theClass, src, w, h)
{
    eImage = document.createElement("img");
    eImage.setAttribute("src",src);
    if (theClass != "")
    {
        eImage.setAttribute("class",theClass);
    }
    if(w!= "")eImage.setAttribute("width",w);
    if(h!= "")eImage.setAttribute("height",h);
    obj.appendChild(eImage);
}


function addMenuItem(obj, theClass, href, theImg, theImg2, id)
{
    eAnchor = document.createElement("a");
    eAnchor.setAttribute("href",href);
    if (theClass != "")
    {
        eAnchor.setAttribute("class",theClass);
    }

    eAnchor.onmouseover = function() { MM_swapImage(id,'',theImg2,1)};
    eAnchor.onmouseout = function() { MM_swapImgRestore()};
    eImage = document.createElement("img");
    eImage.setAttribute("src", theImg);
    eImage.setAttribute("id", id);
    eImage.setAttribute("border", 0);
    eAnchor.appendChild(eImage);

    obj.appendChild(eAnchor);
}

function addLineReturn(obj)
{
    eBr = document.createElement("br");
    obj.appendChild(eBr);
}


function writeBuyLinkUs(product)
{
    price = products[product]["dollar"]
    type  = products[product]["type"]
    code  = products[product]["code"]
    version  = products[product]["version"]
    window.document.writeln("<p class=\"smallish\">")
    window.document.writeln(type + "<br>")
    window.document.writeln("<b>$" + String(price.toFixed(2)) + "</b><br>")
    window.document.writeln("<a href=\"" + SWREG_SERVER_US + "s=" + SWREG_SHOP_US + "&p=" + code + "&v="+ version +"&d=0&q=1&t=m&x=1\">BUY NOW</a>")
    window.document.writeln("</p>")
}


function writeBuyLink(product)
{
    price = products[product]["price"]
    type  = products[product]["type"]
    code  = products[product]["code"]
    version  = products[product]["version"]
    window.document.writeln("<p class=\"smallish\">")
    window.document.writeln(type + "<br>")
    window.document.writeln("<b>&pound;" + String(price.toFixed(2)) + "+VAT</b>")
    window.document.writeln("(&pound;" + String((price * VAT_RATE).toFixed(2)) + " )<br>")
    window.document.writeln("<a href=\"" + SWREG_SERVER + "s=" + SWREG_SHOP + "&p=" + code + "&v="+ version +"&d=0&q=1&t=m&x=1\">BUY NOW</a>")
    window.document.writeln("</p>")
}

function doLoad()
{
    
    
    MM_preloadImages('images/homeOver.gif','images/productsOver.gif','images/supportOver.gif','images/contactsOver.gif', 'images/swapOnVSmall.gif')
  
    addBookmarks()
}


function addBookmarks(){
    //alert("addBookmarks1")
    obj = document.getElementById("socialBookMarks");
    if(!obj)return
    //alert("addBookmarks2")
	var elts = ['digg', 'delicious', 'facebook', 'reddit', 'stumbleupon'];	
	for(var id in elts){
        //alert(elts[id])
		_setIDClick(elts[id]);
	};
};


function _replaceEvent(obj, evt, func) 
{
    //alert("_addEvent")
    obj.href = ""
    var oldEvt = obj[evt];
    if (typeof oldEvt != 'function') { obj[evt] = func;} 
    else {obj[evt] = function() { 
                                //if (oldEvt){oldEvt();}
                                func();
                                }
    }
}


function _setIDClick(id)
	{
        //alert("_setIDClick")
		obj = document.getElementById(id);
        if(!obj)return
		func = function (){_popUpWindow(id);};
		evt = "onclick";
		self._replaceEvent(obj, evt, func);
	}
    
    
function getTitle()
{
	var metaTags = document.getElementsByTagName("meta");
	for (var i = 0; i < metaTags.length; i++) {
	    var tag = metaTags[i];
        
        var tagType = tag.getAttribute("name");
	    if (tagType == "description"){
		    return tag.getAttribute("content");
	    }
        }
    return "";
}

function getUrl()
{
	var metaTags = document.getElementsByTagName("meta");
	for (var i = 0; i < metaTags.length; i++) {
	    var tag = metaTags[i];
        
        var tagType = tag.getAttribute("name");
	    if (tagType == "url"){
		    return tag.getAttribute("content");
	    }
        }
    return "";
}
    
    
function _popUpWindow(id){
    //alert("_popUpWindow")
	var service = id;	
    var url = getUrl();
	var fullStoryUrl = "http://www.lumidium.com/" + url;
    //alert(fullStoryUrl)
	var servUrl;
    var title = getTitle();
	var o = new Object();
	switch(true){
		case service == "delicious":
		servUrl = "http://del.icio.us/post?v=4&noui&jump=close&url=" + fullStoryUrl + "&title=" + title;
		break;
		
		case service == "digg":
		servUrl = "http://digg.com/remote-submit?phase=2&url=" + fullStoryUrl + "&title=" + title;
		break;		
		
		case service == "reddit":
		servUrl = "http://reddit.com/submit?url=" + fullStoryUrl + "&title=" + title;
		break;
		
		case service == "facebook":
		servUrl = "http://www.facebook.com/sharer.php?u=" + fullStoryUrl + "&t=" + title;
		break;
		
		case service == "stumbleupon":
		servUrl = "http://www.stumbleupon.com/submit?url=" + fullStoryUrl + "&title=" + title;
		break;
		
		default:
		break;
		
	};

    window.open( servUrl, "Bookmark", "status = 1, width = 700, height = 500, resizable = 1" )

};



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {//v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

