﻿function openWindow(url, windowName, width, height )
{
    var param;
    param = 'width=' + width + ',height=' + height + 'toolbar=0,resizable=0,scrollbars=1';
    window.open(url,windowName, param);
}


function openProductOverview(page) {
    window.open(page,'ProductOverview','width=700,height=400,toolbar=0,resizable=0,scrollbars=1');
}


function tabClick(clickedTab,pageViewToShow) {                                           
    var tabStrip = clickedTab.parentNode;                                    
    if (tabStrip != null) {
        if (tabStrip.tagName == 'UL' || tabStrip.tagName == 'OL') {
            for (i=0;i<tabStrip.childNodes.length;i++) {                            
                tabStrip.childNodes[i].className = (tabStrip.childNodes[i].id == clickedTab.id) ? tabStrip.className+'Selected' : tabStrip.className+'Default';
            }            
            document.getElementById(tabStrip.id+'PageView').innerHTML = document.getElementById(pageViewToShow).innerHTML;
        }
    }
}
function initTabStrip(oTabStrip) {
    var tabStrip = document.getElementById(oTabStrip); 
    if (tabStrip != null) {
        if (tabStrip.tagName == 'UL' || tabStrip.tagName == 'OL') {
            for (i=0;i<tabStrip.childNodes.length;i++) {  
                tabStrip.childNodes[i].className = (i == 0) ? tabStrip.className+'Selected' : tabStrip.className+'Default';                            
            }
        }
    }
}

function swapImage(img, imgSrc) {
    
    var objImg = document.getElementById(img);
 
    if (objImg != 'undefined') {
        objImg.src = imgSrc;
    }    
    
}

function toggleExpandCollapseWithImg(ctrl,ctrl_img)
{
	var ctrlToToggle = document.getElementById(ctrl)
	var imgToToggle = document.getElementById(ctrl_img)
	if (ctrlToToggle != null && imgToToggle != null)
	{
	    ctrlToToggle.style.display = (ctrlToToggle.style.display == 'none') ? '' : 'none';
	    imgToToggle.src = (ctrlToToggle.style.display == 'none')? '/OL/images/layout/plus-expand.gif': '/OL/images/layout/plus-collapse.gif';
		
	}
	return false;
}

function toggleExpandCollapse(ctrl)
{
	var ctrlToToggle = document.getElementById(ctrl)	
	if (ctrlToToggle != null)
	{
	    ctrlToToggle.style.display = (ctrlToToggle.style.display == 'none')? '':'none';		
	}
	return false;
}



function displayImage(picURL,picWidth,picHeight){
    newWindow=window.open(picURL,'Logo','toolbar=no,width='+picWidth+',height='+picHeight)
    newWindow.document.write('<html><head><\/head><body style="margin:0px"><img src="'+picURL+'"><\/body><\/html>')
    newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
    newWindow.focus()
}


function setCookie(name, value)
         {
         //If name is the empty string, it places a ; at the beginning
         //of document.cookie, causing clearCookies() to malfunction.
         if(name != '')
            document.cookie = name + '=' + value;
         }

function getCookie(name)
         {
         //Without this, it will return the first value 
         //in document.cookie when name is the empty string.
         if(name == '')
            return('');
         
         name_index = document.cookie.indexOf(name + '=');
         
         if(name_index == -1)
            return('');
         
         cookie_value =  document.cookie.substr(name_index + name.length + 1, 
                                                document.cookie.length);
         
         //All cookie name-value pairs end with a semi-colon, except the last one.
         end_of_cookie = cookie_value.indexOf(';');
         if(end_of_cookie != -1)
            cookie_value = cookie_value.substr(0, end_of_cookie);

         //Restores all the blank spaces.
         space = cookie_value.indexOf('+');
         while(space != -1)
              { 
              cookie_value = cookie_value.substr(0, space) + ' ' + 
              cookie_value.substr(space + 1, cookie_value.length);
							 
              space = cookie_value.indexOf('+');
              }

         return(cookie_value);
         }

function clearCookie(name)
         {                  
         expires = new Date();
         expires.setYear(expires.getYear() - 1);

         document.cookie = name + '=null' + '; expires=' + expires; 		 
         }
         
function clearCookies()
         {
         Cookies = document.cookie;
         Cookie = Cookies;
         expires = new Date();
         expires.setYear(expires.getYear() - 1);

         while(Cookie.length > 0)
              {
              //All cookie name-value pairs end with a semi-colon, except the last one.
              Cookie = Cookies.substr(0, Cookies.indexOf(';'));
              Cookies = Cookies.substr(Cookies.indexOf(';') + 1, Cookies.length);

              if(Cookie != '')
                 document.cookie = Cookie + '; expires=' + expires;
              else
                 document.cookie = Cookies + '; expires=' + expires;			  			  	  
              }		 		 
         }




/* Functon Related to the Callbacks done on the ~/Download/Downloads.aspx page */


/************************************************************************************************************/
/*      New functions,                                                                                      */
/*      Author: Arnouldc                                                                                    */
/************************************************************************************************************/
        function Show(id){
            $(".selected").removeClass("selected").addClass("hidden"); 
            $("#" + id).removeClass("hidden").addClass("selected");   
        }
        
        function ImageHover(obj) {
            if (/MSIE (5\.5|6)/.test(navigator.userAgent)) return;
            if (obj.src.match(/-on((.[a-z][a-z])?\.(gif|png|jpg))/)) {
                var re = RegExp('-on((.[a-z][a-z])?\.(gif|png|jpg))'); 
                obj.src = obj.src.replace(re, '$1');                   
            } else {
                var re = new RegExp(/((\.[a-z][a-z])?\.(gif|png|jpg))/);
                obj.src = obj.src.replace(re, '-on$1');                     
            }
        }
        

//        function LoadThisImage(loader, pCallback){
//            image_src = loader.attr('src');
//            img = new Image();
//            img.hide();

//            img.load(function() {
//                cb_js = loader.get(0).getAttribute(‘onload');
//                onload_cb = function(){
//                    eval(cb_js);
//                }       
//                
//                loader.html(this);
//                loader.removeClass(‘loadable-image');
//                loader.removeAttr('src');
//                loader.removeAttr(‘onload');
//                $(this).show(); 
//                if (onload_cb){  
//                    onload_cb($(this));
//                }    
//                if (pCallback){
//                    cb = pCallback;
//                    cb($(this));
//                }
//            })
//            .error(function() { $(this).attr('src', gFailImage).show(); })
//            .attr('src', image_src)
//            .show();
//        }


        function EnlargePhoto(littleImgID, linkID){
            var re = new RegExp(/((\.[a-z][a-z])?\.(gif|png|jpg))/);
            littleImg = document.getElementById(littleImgID);
            var img = document.getElementById('EnlargedPhoto');  
            img.src = littleImg.src.replace(re, '-on$1');

            if (linkID == null) {
                $("#LinkPdf").addClass("hidden");
            }else{
                $("#LinkPdf").removeClass("hidden");
                document.getElementById('LinkPdf').href = document.getElementById(linkID).href;
            }
            $("#EnlargePhotoBackground").removeClass("hidden");
            $("#EnlargePhoto").removeClass("hidden");
            window.scrollTo(0,200);
        }
        
        function ClosePhoto(){
            $("#EnlargePhotoBackground").addClass("hidden");
            $("#EnlargePhoto").addClass("hidden");
        }
        
        function ShowPopUp(id, img){
            // $("#" + id).slideDown("slow"); 
            $("#" + id).animate({opacity: "show", top: "0"}, "slow");;
            //$("#" + id).slideDown().animate({opacity:1})
 
            if (img != null) ImageHover(img);     
        }
        
        function HidePopUp(id, img){
            //$("#" + id).slideUp("fast");
            //$("#" + id).animate({opacity: "hide", top: "-70"}, "fast");
            $("#" + id).hide();
            if (img != null) ImageHover(img);
        }