function feedback(type, message) {
    var cls = 'success-msg';
    switch (type) {
        case('WARN'):
            cls = 'warning-msg';
            break;
        case('ERROR'):
            cls = 'error-msg';
            break;
        case('INFO'):
            cls = 'info-msg';
            break;
    }
    var feedbackDiv = document.getElementById('error-header');
    if (feedbackDiv) {
        var html = '<p>' +  message + '</p>';      
        feedbackDiv.innerHTML = html;
    }
}

function clearFeedback() {
    var feedbackDiv = document.getElementById('error-header');
    if (feedbackDiv) {
        feedbackDiv.innerHTML = '';
    }
}

function openPopUp(location){
    var extWin = window.open( location, "", 'left=20,top=20,width=1000,height=600,toolbar=0, scrollbars=1, resizable=0,' +
                                            'menubar=0, location=0, directories=0, status=0');
}

function checkoutTrackBack(form, index, trackerId){

    switch (index) {
    case 0:   _gaq.push(['_trackPageview','/virtual/checkout/account_details.html']);
        break;

    case 1:  _gaq.push(['_trackPageview','/virtual/checkout/billing_address.html']);
        break;

    case 2:  _gaq.push(['_trackPageview','/virtual/checkout/delivery_address.html']);
        break;

    }

}

function paymentTrackBack(form, trackerId){
    _gaq.push(['_trackPageview','/virtual/checkout/payment_started.html']);
}

function guestCheckoutTrackBack(form, index, trackerId){

    switch (index) {
    case 0:  _gaq.push(['_trackPageview','/virtual/checkout/guest_billing_address.html']);
        break;

    case 1:  _gaq.push(['_trackPageview','/virtual/checkout/delivery_address.html']);
        break;

    }

}

function openVideo(data){
    var myArray = data.split(/ +/);
    var url = "";
    var h="height=520";
    var w="width=600";
    var width = 600;
    var height = 520;

       for (i=0; i<myArray.length; i++) {
            var str = myArray[i];
            if (str.match(/^url/)){
                   url = str.replace(/^url=/, "");               
            } else if (str.match(/^width/)){
                w = str;
                var tArray = w.split(/=/);
                width = tArray[1];
            } else if (str.match(/height/)){
                h = str;
                  tArray = h.split(/=/);
                  height = tArray[1];
            }
       }

    if (url.match(/youtube/)) {
        var winWidth = (width * 1) + 15;
        var winHeight = (height * 1) + 15;

        var optionString = "status=no, toolbar=no, location=no, menubar=no, directories=no, resizable=no, scrollbars=no";
        optionString += ", width=" + winWidth + ", height=" + winHeight;
        optionString += ", " + "right=" + (screen.width - 100) + ", top=50";

        var myWin = window.open("", '', optionString);

        var s = '<object width="' + width + '" ';
        s += 'height="' + height + '"><param name="movie" value="';
        s += url;
        s += '></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src=';
        s += url;
        s += ' type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false"';
        s += ' width="' + width + '"';
        s += ' height="' + height + '"></embed></object>';

        var s1 = "<html><head><title>Science Museum</title></head><body bgcolor='#F0037F' style='background-repeat: no-repeat;'>" + s + "</body></html>";
        myWin.document.write(s1);

    } else {
        var optionString2 = "status=no, toolbar=no, location=no, menubar=no, directories=no, resizable=no, scrollbars=no, toolbar=no, titlebar=no";
        optionString2 = optionString2 + ", " + w + ", " + h;
        optionString2 = optionString2 + ", " + "right=" + (screen.width - 100) + ", top=50";       
        window.open(url, '_blank', optionString2);
    }


    return false;       
                                
}


function openWindow(location){
    var extWin = window.open( location, "", 'left=20,top=20,width=1000,height=600,toolbar=0, scrollbars=1, resizable=0,' +
                                            'menubar=0, location=0, directories=0, status=0');
}

