
function clientURL(target,customer){
        address =  "http://" + "www." + target;
        document.write("<a href='" +address + "' target='_blank' class='link'>");
        document.write(customer);
        document.write("</a>");
}

function readCookie(name){
         var cookieValue = "";
         var search = name + "=";
         if(document.cookie.length > 0){
             offset = document.cookie.indexOf(search);
             if (offset != -1){
                    offset += search.length;
            	     end = document.cookie.indexOf(";", offset);
            	     if (end == -1) end = document.cookie.length;
            	     cookieValue = unescape(document.cookie.substring(offset, end));
             }
         }
         return cookieValue;
}

// if the number is less than 10 we add a 0
function checkFormat(idx){
    if(idx < 10){
      idx = "0" + idx;
    } 
    return idx;
}

function writeCookie(name, value, hours, path){
        var expire = "";
        var mydate= new Date();
        var theyear=mydate.getFullYear();
        var themonth=mydate.getMonth()+1;
        var thetoday=mydate.getDate();
        var hour=mydate.getHours();
        var minutes=mydate.getMinutes();
        var seconds=mydate.getSeconds();
        
        if(hours != null){
            	expire = new Date((new Date()).getTime() + hours * 3600000);
            	expire = "; expires=" + expire.toGMTString();
        }
        date = theyear+"-"+checkFormat(themonth)+"-"+checkFormat(thetoday)+" "+checkFormat(hour)+":"+checkFormat(minutes)+":"+checkFormat(seconds);
        values = date + "|" + value;  

        document.cookie = name + "=" + values + expire + "; path = " + path;
 //  alert("Value: " + values);
}
            
function checkCookie(){
        // check if the cookie is set
        if ( readCookie("ref") == "" ){
            // if not, we set the 'ref' cookie. The value contains the date + referral;
            var refCookie = document.referrer;
            
            //
            // Referrals from Google Adwords comes to oxygenxml.com?adw=true and
            // the referral must be changed from google.com?.. to google-adw.com?... 
            //
            var url = String(window.location);
            var index = url.indexOf("?");
            var data = url.substr(index+1);            
            // alert("URL: " + url + "\nDATA: " + data);
            
            if (data.match('adw')){
                // alert ("Referral from Google ADW. Alter the referral var");
                if (refCookie == '') {
                    referral = "www.google-adw.com/";
                } else {
                    referral = refCookie.replace(/google./g, "google-adw.");
                    // alert("Ref: " + referral);
                }
            } else {
                referral = refCookie;
            }
            
            writeCookie("ref",referral, 65000, "");            
       }
}
            
function sendEmail(part1,part2) {
        address =  part1 + "@" + part2;
        document.write("<a href='mailto:" +address + "' class='link'>");
        document.write(address);
        document.write("</a>");
}                      

function blurOn(form) {
    if (form.query.value == '') {
        form.query.value = 'Search';
    }
}


function showHint(name){
    var val = name;
    document.getElementById(val).className = "showHint";
}            

function hideHint(name){
    var val = name;
    document.getElementById(val).className = "hide";
}            



function hideDiv(name) {
    var val = name;
    var x = document.getElementsByTagName("div");
    for (i = 0; i < x.length; i++) {
        if (x[i].id.match(val)) { 
            x[i].className = "hide";
        }    
    }
}
      
      
function show_sshot(name){
      var value = name;
      product=value.split("-");
      productID = product[1]; 
      
      hideDiv('s_');
           
      var x = document.getElementsByTagName("div");
      document.getElementById(productID).className = 'show';
}
      
// Events programme - show randomly a div which contains an upcoming event
function show_event(){
      var randomnumber=Math.floor(Math.random()*2);
      event_ID = "oxy_event" + randomnumber;
      hideDiv('oxy_event');
      document.getElementById(event_ID).className= "show";
}

