// JavaScript Document
function fixIEPng() {
//    var arVersion = navigator.appVersion.split("MSIE")
//    var version = parseFloat(arVersion[1])

//    if (version && version >= 5.5 && version < 7 && document.body.filters) {
//        for(var i = 0; i < document.images.length; i++)
//        {
//            var img = document.images[i];
//            var imgName = img.src.toUpperCase();
//            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
//                var imgID = (img.id) ? "id='" + img.id + "' " : "";
//                var imgClass = (img.className) ? "class='" + img.className + "' " : "";
//                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
//                var imgStyle = "display:inline-block;" + img.style.cssText;
//                if (img.align == "left") imgStyle = "float:left;" + imgStyle;
//                if (img.align == "right") imgStyle = "float:right;" + imgStyle;
//                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
//                var strNewHTML = "<span " + imgID + imgClass + imgTitle
//				    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
//				    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
//				    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
//                img.outerHTML = strNewHTML
//            }
//        }
//    }
}
function doPageLink() {
    var args = getArgs();
    if (args["Preview"] || args["preview"]) {
        document.write("<a class='bPager' href=\"javascript:window.close()\">Close window</a>");
        var elem = document.getElementById("StdFooterSnippetContainer");
        if (elem)
            elem.style.display = "none";
    }
    else
        document.write("<a class='bPager' href=\"javascript:history.back()\">Previous page</a>");
}
function roundPrice(p) {
    var pound = String.fromCharCode(163);
    var price = pound + (new Number(p)).toFixed(2);
    return price;
}
String.prototype.endsWith = function(s) {
    return s == this.substr(this.length - s.length);
}
function getArgs() {
    var args = new Object();
    var query = location.search.substring(1);
    var pairs = query.split("&");
    for (var i = 0; i < pairs.length; i++) {
        var nIndex = pairs[i].indexOf('=');
        if (nIndex == -1)
            continue;
        var name = pairs[i].substring(0, nIndex);
        var val = pairs[i].substring(nIndex + 1);
        //		args[name] = unescape(val);
        args[name] = decodeURIComponent(val);
    }
    return args;
}
//function findPosition(obj) {
//    if (obj.offsetParent) {
//        for (var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent) {
//            posX += obj.offsetLeft;
//            posY += obj.offsetTop;
//        }
//        return [posX, posY];
//    }
//    else {
//        return [obj.x, obj.y];
//    }
//}
function findPosition(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft, curtop];
    }
}
function switchImg(img) {
    if (img.src.indexOf("_f2") != -1)
        img.src = img.src.replace(/_f2/, "");

    else {
        img.src = img.src.replace(/\.gif/, "_f2\.gif");
        img.src = img.src.replace(/\.jpg/, "_f2\.jpg");
        img.src = img.src.replace(/\.png/, "_f2\.png");
    }
}
function preload() {
    imgs = new Array(arguments.length);
    for (var i = 0; i < arguments.length; i++) {
        imgs[i] = new Image();
        imgs[i].src = arguments[i];
    }
}
function checkStatus() {
    if (document.forms[0]["Status"] && document.forms[0]["Status"].value) {
        alert(document.forms[0]["Status"].value);
        document.forms[0]["Status"].value = "";
        return false;
    }
    return true;
}
var imgs = null;

function openWindow(url, winName, top, left, width, height, scrll) {
    this.width = arguments.length > 4 ? width : 800;
    this.height = arguments.length > 5 ? height : 340;
    this.scrll = arguments.length > 6 ? scrll : "yes";

    return window.open(url, winName, "width=" + this.width + ",height=" + this.height + ",location=no,toolbar=no,menubar=no,titlebar=yes,scrollbars=" + this.scrll + ",resizable=yes,top=" + top + ",left=" + left);
}

function doLink2(url, w, h, bScroll) {
    var left = screen.availWidth > 800 ? 30 : 0;
    var top = screen.availHeight > 480 ? 30 : 0;

    var width = arguments.length > 1 ? w : 640;
    var height = arguments.length > 2 ? h : 480;

    var scrll = arguments.length > 3 ? "yes" : "no";

    if (childWin2 && !childWin2.closed) {
        childWin2.location = url;
        childWin2.focus();
        return;
    }

    childWin2 = openWindow(url, "ChildWindow2", top, left, width, height, scrll);
}

function doLink(url, w, h, bScroll) {
    var left = screen.availWidth > 800 ? 60 : 0;
    var top = screen.availHeight > 600 ? 60 : 0;

    var width = arguments.length > 1 ? w : 640;
    var height = arguments.length > 2 ? h : 480;

    var scrll = arguments.length > 3 ? "yes" : "no";

    if (childWin && !childWin.closed) {
        childWin.location = url;
        childWin.focus();
        return;
    }

    childWin = openWindow(url, "ChildWindow", top, left, width, height, scrll);
}

function killChild() {
    try {
        if (childWin2 && !childWin2.closed)
            childWin2.close();

        if (childWin.childWin2 && !childWin.childWin2.closed)
            childWin.childWin2.close();

        if (childWin && !childWin.closed)
            childWin.close();
    }
    catch (ex) {
        //	Ignore permission denied errs
    }
}
function doPrint(url, w, h) {
    if (arguments.length < 3)
        h = 500;

    if (arguments.length < 2)
        w = 700;

    doLink(url, w, h, false);
}
function doTrustHeaderScript() {
    if (isTrustLogoEnabled) {
        var cot_loc0 = (window.location.protocol == "https:") ? "https://secure.comodo.net/trustlogo/javascript/cot.js" : "http://www.trustlogo.com/trustlogo/javascript/cot.js";
        document.writeln('<scr' + 'ipt language="JavaScript" src="' + cot_loc0 + '" type="text\/javascript">' + '<\/scr' + 'ipt>');
        headerScriptExists = true;
    }
}
var headerScriptExists = false;

function insertTrustLogo(webAddress) {
    if (headerScriptExists) {
        if (webAddress) {
            if (COT && window.location.protocol == "https:")
                COT("https://" + webAddress + "/assets/secure_site.gif", "SC2", "none");

            else if (COT)
                COT("http://" + webAddress + "/assets/secure_site.gif", "SC2", "none");
        }
        else
            COT("assets/secure_site.gif", "SC2", "none");
    }
}
function isPrinting() {
    var p = getArgs()["Print"];
    if (p) {
        p = getArgs()["Preview"];
        return p && p == "1";
    }
    return false;
}
function onLoadEx() {
    if (isPrinting()) {
        document.body.style.padding = "50px";
        print();
    }
}
//3.3.0
function addFavourite(url, title) {
    if (!isIE())
        return;

    this.url = arguments.length > 0 ? url : location.href;
    this.title = arguments.length > 0 ? title : document.title;

    window.external.AddFavorite(this.url, this.title);
}
function isIE() {
    return navigator.appName.indexOf('Microsoft') != -1 && navigator.userAgent.indexOf('MSIE') != -1;
}
//2.7.0
/*
function saveClient(doReload)
{
if(!isCookiesEnabled())
return;
			
var cookie = new Cookie(document, "client");	
var bReload = !cookie.load();
	
if(arguments.length)
bReload = bReload && doReload;
	
//	cookie.docWidth = document.body.offsetWidth;
//	cookie.docHeight = document.body.offsetHeight;	
cookie.screenWidth = screen.availWidth;
cookie.screenHeight = screen.availHeight;
	
//	if(plugins)
//	{
//		cookie.flash = isFlashInstalled() ? "True" : "False";
//		cookie.quicktime = isQuickTimeInstalled() ? "True" : "False";
//		cookie.director = isDirectorInstalled() ? "True" : "False";
//		cookie.real = isRealPlayerInstalled() ? "True" : "False";
//		cookie.java = isJavaInstalled() ? "True" : "False";
//		cookie.windowsmediaplayer = isWindowsMediaPlayerInstalled() ? "True" : "False";
//	}		
	
	
cookie.store();
if(bReload)
location.reload();
}
function isCookiesEnabled()
{
var cookie = new Cookie(document, "test");
cookie.test = "test";
cookie.store();
if(cookie.load())
{
cookie.remove();
return true;
}
return false;
}
*/
function fixIEFlashPrompt() {
    theObjects = document.getElementsByTagName("object");
    for (var i = 0; i < theObjects.length; i++)
        theObjects[i].outerHTML = theObjects[i].outerHTML;
}
function onPCFocus(pc) {
    if (pc.value.toLowerCase() == "post code")
        pc.value = "";
}
function onPCBlur(pc) {
    if (pc.value == "")
        pc.value = "post code";
}
//2.7.0 ends
//3.0
function isPreview() {
    return getArgs()["Preview"] == 1;
}
function isPopup() {
    return getArgs()["Popup"] == 1;
}

var childWin = null;
var childWin2 = null;
//saveClient(screen.availWidth < 1000); //3.0.21
onfocus = killChild;
var COT = null;
var isTrustLogoEnabled = false;
doTrustHeaderScript();
