// include prototype.js, effects.js and combo.js before

function isIE() 
{
    return ((navigator.userAgent.toLowerCase().indexOf("msie")!= -1)&&!window.opera)? true : false;     
}

var g_dakisGalleryImages = new Array();
var g_dakisNbImageGalleries = 0;

/*
    Function: dakisCreateRolloverImageGallery
    Show the large image when mouse over the thumbnail. Set the onmouseover
    handler of each thumbnail to change the full image element source to the
    large image file.    
	
	May have multiple galleries on the same page by calling this function multiple
	times after each serie of images. The gallery number will be appended to the fullImage element id.	
    
    changeImageEvent: onmouseover, onclick
    [textElementId]: the alt text of the selected image will be put in this element
*/
function dakisCreateImageGallery(thumbnailClass, changeImageEvent, fullImageElementId, fullImageSuffix, selectedImageClass, textElementId)
{
    thumbnails = document.getElementsByClassName(thumbnailClass);
	firstThumbnail = null;
	
	if( g_dakisNbImageGalleries > 0 )
	{
		fullImageElementId = fullImageElementId + (g_dakisNbImageGalleries+1).toString();
	}
	
	fullImageElement = $(fullImageElementId);
	if( fullImageElement == null )
	{
		alert("Gallery Image Error: The large gallery image element doesn't exist. Make sure an element has the id: "+fullImageElementId);
		return;
	}

	if( fullImageElement.tagName.toLowerCase() != "img" )
	{
		alert("Gallery Image Error: The large gallery must be an image. It is actually a: "+fullImageElement.tagName);
		return;
	}
    
    
    thumbnails.each(function(thumbnail){
	
		// not already added in another gallery?
		if( g_dakisGalleryImages.indexOf(thumbnail) == -1 )
		{	
			g_dakisGalleryImages.push(thumbnail);
			thumbnail.galleryImageId = g_dakisNbImageGalleries;
			
			if( firstThumbnail == null )
			{
				firstThumbnail = thumbnail;
			}
			
			var extension = dakisGetFileExtension(thumbnail.src);
			var newExtension = fullImageSuffix+"."+extension;
			var largeFile = dakisSetFileExtension(thumbnail.src, newExtension);
			var text = thumbnail.alt;
			
			// preload large image...
			var image = new Image();
			image.src = largeFile;
			
			thumbnail[changeImageEvent] = function(){
				
				// deselect the current thumbnail...
				g_dakisGalleryImages.each(function(t){          
					if( t.galleryImageId == thumbnail.galleryImageId )
					{
						t.classNames().add(thumbnailClass);
						t.classNames().remove(selectedImageClass);
					}
				});
				
				// select the new one...
				thumbnail.classNames().add(selectedImageClass);
				thumbnail.classNames().remove(thumbnailClass);
				
				if( textElementId != undefined && $(textElementId) != null)
				{
					$(textElementId).innerHTML = text;
				}
				
				if( $(fullImageElementId).src == largeFile )
				{
					return; // large file already visible...
				}
				
				// cute transition effect to show the new large image...
				new Effect.Opacity  (fullImageElementId, 
									{ from: 1.0, to: 0.6, duration: 0.15, afterFinish: function(){
											$(fullImageElementId).src = largeFile;
											new Effect.Opacity(fullImageElementId, { from: 0.6, to: 1.0, duration: 0.3 });											
										}
									});            
			};
		}
    
    });   
    
	if( firstThumbnail == null )
	{
		alert("Gallery Image Error: No thumbnail found for the full image element id: "+fullImageElementId);
	}
	
    // show the first thumbnail...
    firstThumbnail[changeImageEvent]();

	g_dakisNbImageGalleries++;
}


function templateOnImageMouseHover(image, originalSrc, hoverSrc)
{
	new Effect.Opacity(image, 
							{ from: 1.0, to: 0.6, duration: 0.12, afterFinish: function(){
									image.src = hoverSrc;
									new Effect.Opacity(image, { from: 0.6, to: 1.0, duration: 0.2 });									
								}
							});
}

function templateOnImageMouseOut(image, originalSrc, hoverSrc)
{
	if( originalSrc == hoverSrc)
	{
		return;
	}
	
	new Effect.Opacity(image, 
							{ from: 1.0, to: 0.6, duration: 0.12, afterFinish: function(){
									image.src = originalSrc;
									new Effect.Opacity(image, { from: 0.6, to: 1.0, duration: 0.2 });									
								}
							});
}

/*
    Function: dakisButtonUpEvent
    Do the effect to make a button appears "up" 
*/
function dakisButtonUpEvent(element)
{
    //element.style.backgroundPosition = "0px center";
    Element.setOpacity(element, 1);
}

/*
    Function: dakisButtonDownEvent
    Do the effect to make a button appears "down" 
*/
function dakisButtonDownEvent(element, width)
{  
    //var width = element.offsetWidth;    
    //var offset = "-"+width+"px center";
    
    //element.style.backgroundPosition = offset;
    
    
    Element.setOpacity(element, 0.75);
}

function dakisBackToTop()
{
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("dakisBackToTop()", 25);
    }
}

/*
    Function: loadAdRotators
    Create one ad rotator object per element of the dakisAdRotator class name.  So anywhere
    you want an adrotator, just place a div element with the special class name.
    
    Parameters:
    
    templateElementId - element which contains placeholders to be replaced by actual product's values.
    
    Example:
    
    <div class="dakisAdRotator">
        <!-- content goes here -->
    </div>
*/
function dakisLoadAdRotators(templateElementId)
{
    var id = 0; 
    var adRotators = document.getElementsByClassName("dakisAdRotator");
    
    adRotators.each(function(element)
    {
        element.id = "dakisAdRotator"+id;
        
        var advertiser = new DakisProductAdvertiser2(element.id, templateElementId);
        advertiser.imageWidth = g_dakisAdRotatorImageWidth;
        advertiser.imageHeight = g_dakisAdRotatorImageHeight;
        advertiser.delay = g_dakisAdRotatorDelay;
        advertiser.afterMerchandiseImported = dakisProcessImportedProduct;
        advertiser.start();
        
        id++;
    });
}

function dakisLoadAdRotators2(templateElementId, host, retailer_guid, lang)
{
    var id = 0; 
    var adRotators = document.getElementsByClassName("dakisAdRotator");
    for(var t=0; t<adRotators.length; t++ )    
    {
        element = adRotators[t];
        element.id = "dakisAdRotator"+id;        
        
        var advertiser = new DakisProductAdvertiser2(element.id, templateElementId);
        advertiser.host = host;
        advertiser.retailer_guid = retailer_guid;
        advertiser.lang = lang;
        advertiser.imageWidth = g_dakisAdRotatorImageWidth;
        advertiser.imageHeight = g_dakisAdRotatorImageHeight;
        advertiser.delay = g_dakisAdRotatorDelay;
        advertiser.afterMerchandiseImported = dakisProcessImportedProduct;
        advertiser.start();
        
        id++;
    };
}

function dakisProcessImportedProduct(id, merchandise, nbMerchandises)
{
    // if on sale, show both sale and reg prices...
    if( merchandise.flag == "sale" )
    {   
        
        var isMap = merchandise.MAP != undefined && merchandise.MAP == true;
        
        var regPriceElement = $(id+"_regpriceDiv");
        if( regPriceElement != null )
        {   
            regPriceElement.style.display = "block";            
            
            if( isMap )
            {                
                regPriceElement.innerHTML = "see price in cart!";
            }
        }
        
        if( isMap )
        {
            // show only regular price and tell to see cart for better price..!
            var ourPriceElement = $(id+"_ourprice");            
            if( ourPriceElement != null )
            {
                ourPriceElement.innerHTML = merchandise.regPrice;
            }
        }
    }
}

/*
    Function: zoomToStore
    Zoom and center on a store.  May be called only when the dakis map
    iframe is loaded.  Intented to be used to create links beside the map
    for each retailer's store.
    
    Parameters:
    
    index - store indentifier from 0 to the number of store - 1.  The order
            is the same as the stores appear in the store selector.
*/
function zoomToStore(index)
{   
    var storeIndexArgName = "index";
    var src = document.getElementById('dakisMapFrame').src;
    var storeIndexPos = src.indexOf(storeIndexArgName+"=");
    
    if( storeIndexPos != -1 )
    {
        src = src.substr(0, storeIndexPos-1);        
    }    
    
    src = src + "&"+storeIndexArgName+"="+index;    
    
    document.getElementById('dakisMapFrame').src = src;
}

/*
    Function: resizeToFitParentElement
    Resize an element height according to its container
*/
function resizeToFitParentElement(element)
{       
    // set map height since height:100% doesn't work 
    var parentNode = element.parentNode;
    
    while( parentNode != null )
    {
        if( parentNode.tagName != "FONT" &&
            parentNode.tagName != "P" &&
            parentNode.style.height != null &&
            parentNode.style.height.indexOf("px") != -1)
        {
            element.style.height = parentNode.style.height;
            if( parentNode.style.width != null || element.offsetWidth == 0 )
            {   
                if( parentNode.clientWidth != null && parentNode.clientWidth != 0)
                {
                    element.style.width = parentNode.clientWidth;
                }
                else if( parentNode.offsetWidth != null && parentNode.offsetWidth != 0)
                {
                    element.style.width = parentNode.offsetWidth;
                }
                else if( parentNode.style.width != null &&
                        parentNode.style.width.indexOf("px") != -1)
                {
                    element.style.width = parentNode.style.width;
                }               
                
            }
            break;
        }
        
        parentNode = parentNode.parentNode;
    }
}

/*
    Function: includeJsIfUndefined
    Dynamically include a javascript file if not already included.  For example,
    when Prototype.js is included, the Prototype variable is defined with the version
    number and other information.
    
    Parameters:
    
    testVar - include if this variable is undefined
    jsPath - js file url
*/
function includeJsIfUndefined(testVar, jsPath)
{
    if(testVar == undefined)
    {
        includeJs(jsPath);        
        testVar = "defined";
    }
}

/*
    Function: includeJs
    Dynamically include a javascript file
    
    Parameters:    
    
    jsPath - js file url
*/
function includeJs(jsPath)
{
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="'+jsPath+'">');
    document.write('</' + 'script' + '>');
}

/*
    Function: redirectToPrintAppIfNeeded
    Redirect to an online print app if not already done.  Once redirected,
    the isRemoteLayout var is defined by the server.
*/
function redirectToPrintAppIfNeeded(serverUrl, lang, retailerGuid, appVersion)
{
        try
        {        
            var remote = isRemoteLayout;
        }
        catch(e)
        {        
            // not defined, so the redirect hasn't been done yet        
            redirectToPrintApp(serverUrl, lang, retailerGuid, appVersion);                 
        }    
}

/*
    Function: redirectToPrintApp
    Redirect to an online print page
    
    parameters:
    
    appVersion - photo_prints, gifts, photo_prints_flash, gifts_flash
*/
function redirectToPrintApp(serverUrl, lang, retailerGuid, appVersion)
{   
    var baseUrl = getDocDomainDir();
    var pageFile = window.location.pathname.substring(window.location.pathname.lastIndexOf("/")+1);
    var date = new Date(Date.parse(document.lastModified));
    var version = date.getMonth()+"/"+date.getDate()+"/"+date.getFullYear()+"%20"+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
    
    
    var url =   serverUrl + "/guid/"+retailerGuid+"/"+lang+"/photo/"+appVersion+"?"+
                "base_url="+baseUrl+
                "&page_file="+pageFile+
                "&page_version="+version+
                "&lang="+lang+
                "&retailer_guid="+retailerGuid;
    
    window.location.replace(url);            
}

/*
    Function: redirectToCashierIfNeeded
    Redirect to an online cashier if not already done.  Once redirected,
    the isRemoteLayout var is defined by the server.
*/
function redirectToCashierIfNeeded(serverUrl, lang, retailerGuid, sessionId)
{
        try
        {        
            var remote = isRemoteLayout;
        }
        catch(e)
        {        
            // not defined, so the redirect hasn't been done yet        
            redirectToCashier(serverUrl, lang, retailerGuid, sessionId);                 
        }    
}

/*
    Function: redirectToCashier
    Redirect to an online cashier    
*/
function redirectToCashier(serverUrl, lang, retailerGuid, sessionId)
{   
    var baseUrl = getDocDomainDir();
    var pageFile = window.location.pathname.substring(window.location.pathname.lastIndexOf("/")+1);
    var date = new Date(Date.parse(document.lastModified));
    var version = date.getMonth()+"/"+date.getDate()+"/"+date.getFullYear()+"%20"+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
    
    
    var url =   serverUrl + "/paypal_standard?"+
                "base_url="+baseUrl+
                "&page_file="+pageFile+
                "&page_version="+version+
                "&lang="+lang+
                "&session_id="+sessionId+
                "&retailer_guid="+retailerGuid;
    
    window.location.replace(url);            
}

/* 
    Function: setElementClass
    Helper function to set class name correctly in IE and other browsers    
*/
function setElementClass(element, className)
{
    element.setAttribute("class", className);
    element.setAttribute("className", className);
}

/*
    Ask the user to bookmark this page
*/
function bookmarkThisPage()
{            
    if (document.all)
    {                
        window.external.AddFavorite(document.URL, document.title);
    }
    else if (window.sidebar)
    {                
        window.sidebar.addPanel(document.title, document.URL, "")
    }           
}

/*
    Function: popupwindow
    Display a popup window
    
    Parameters:
    
    url - the source of the popup
    args - argument following the ? in the url string
    width - window width.  0 to be full screen.
    height - window width. 0 to be full screen.
    centered - whether to center the window
    menubar - whether to display the browser menu 
    scrollbars - whether to display scrollbars if the content is too large
    resizable - whether the user should be able to resize the window
    
*/
function dakisPopupWindow(url, args, width, height, centered, menubar, location, scrollbars, resizable)
{
    if( g_designMode ){return;}
    var left = 0;
    var top = 0;
    
    if( width == 0 || height == 0 )
    {
        width = screen.width;
        height = screen.height;
    }
    
    if( centered )
    {
        left = (screen.width - width) / 2;
        top = (screen.height - height) / 2;
    }
    
    var params = 'width='+width+',height='+height+',left='+left+',top='+top+', menubar='+menubar+', toolbar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable+',location='+location;
    if( args != '' )
    {
        url += '?'+args;
    }
    
    var popup=window.open(url,window.location.href+"_popup",params);
    popup.focus();
}

function winopen(url,width,height, args)
{
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width='+width+',height='+height+',left='+left+',top='+top+'menubar=no,scrollbars=yes,resizable=no,location=no'
    var popup=window.open(url+'?'+args,'popup',params);
    popup.focus();
}

function winopenResizable(url,width,height, args)
{
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width='+width+',height='+height+',left='+left+',top='+top+'menubar=no,scrollbars=yes,resizable=yes,location=no'
    var popup=window.open(url+'?'+args,'popup',params);
    popup.focus();
}

function flashAppOpen()
{
    flashAppOpenArgs('');
}

function flashAppOpenProduct(productGuid)
{
    flashAppOpenArgs('skipL=true&p1='+productGuid);
}

function flashAppOpenPL(plGuid)
{
    flashAppOpenArgs('pl='+plGuid);
}

function flashAppOpenDM(dmGuid)
{
    flashAppOpenArgs('dm='+dmGuid);
}

function templateOnLink(url)
{
    // if a link inside the website, make sure the content is visible
    if( url.indexOf('http://')==-1)
    {
        refreshVisibleContentDivFromHref(url);            
    }
}


DakisFlashObject = Class.create();
DakisFlashObject.prototype = {
	objectWidth: 0,
	objectHeigth: 0,
	htmlElementId: 'dhe_flash_object',
	created: false,
	cssUrl: 'none',
	flashUrl: '',
	className: 'dhe_flash_object',
	callbackObj: '',
	randomized: false,
	
	initialize: function(callbackObj,flashUrl,w,h,htmlElementId,cssUrl)
	{
		this.callbackObj = callbackObj;
		this.flashUrl = this.getPublicUrl(flashUrl, {obj: callbackObj, cssUrl: cssUrl, language: g_dakisLang});
		this.objectWidth = w;
		this.objectHeigth = h;		
		if(htmlElementId !== undefined){
			this.htmlElementId = htmlElementId;
			this.className = htmlElementId;
		}			
		if(cssUrl !== undefined)
			this.cssUrl = cssUrl;
	},
	hideObject: function()
	{
		$(this.htmlElementId).style.visibility = "hidden";
		$(this.htmlElementId).style.display = "none";
		removeOverlay();
	},
	promptObject: function()
	{
		if(!this.created)
			this.createObject();
		this.showObject();
	},
	createObject: function()
	{
		var self = this;
		var someRand = Math.floor(Math.random()*10);
		this.addObjectDiv();
		var so = new SWFObject(this.flashUrl, "flashObj"+someRand, this.objectWidth, this.objectHeigth, "7", "#FFFFFF");
		so.write(this.htmlElementId);
		this.created = true;
	},
	addObjectDiv: function()
	{
		var bodyElem = document.getElementsByTagName("body")[0];
		var obj = document.createElement("div");
		obj.setAttribute( 'id', this.htmlElementId );
		obj.className = this.className;
		obj.style.zIndex = '102';
		obj.style.position = "absolute";
		obj.style.display = "none";
		obj.style.visibility = "hidden";
		bodyElem.appendChild( obj );
	},
	showObject: function()
	{
		$(this.htmlElementId).style.visibility = "visible";
		$(this.htmlElementId).style.display = "block";
		this.positionMiddle();
		addOverlay();
	},
	positionMiddle: function()
	{
		var element = $(this.htmlElementId);
		var windowHeight;
		var windowWidth;
		var scrolled;

		if( ie )
		{
			if (document.documentElement && document.documentElement.clientHeight){
				windowHeight = document.documentElement.clientHeight;
				windowWidth = document.documentElement.clientWidth;
			}
			else{
				windowHeight = document.body.clientHeight;
				windowWidth = document.body.clientWidth;
			}
			scrolled = document.documentElement.scrollTop;
		}
		else
		{
			windowHeight = self.innerHeight;
			windowWidth = self.innerWidth;
			scrolled = pageYOffset;
		}

		element.style.top = "0px";
		element.style.left = "0px";

		element.style.top = Math.round(scrolled + windowHeight/2 - element.clientHeight/2) + "px";
		element.style.left = Math.round(windowWidth/2 - element.clientWidth/2) + "px";
	},
	getPublicUrl: function(fileName, params){
		if(params !== undefined)
			return g_dakisServerUrl + fileName + '?' + $H(params).toQueryString();
		else
			return g_dakisServerUrl + fileName;
	}
};

//***************************************************
//	Class: DakisDHEBanner
//	Class and object handling the banners
//***************************************************
DakisDHEBanner = Class.create();
Object.extend( DakisDHEBanner.prototype, DakisFlashObject.prototype );
Object.extend( DakisDHEBanner.prototype,{
	imageDelay: 5000,
	imagePath: './../images/banner/',
	randomized: false,
	transparency: false,
	initialize: function(flashUrl,htmlElementId,imagePath,delay,transparency){
		this.flashUrl = flashUrl;
		this.imagePath = imagePath;
		this.imageDelay = delay;
		this.transparency = transparency;
		if(htmlElementId !== undefined)
		{
			this.htmlElementId = htmlElementId;
			this.className = htmlElementId;
			
			var el = document.getElementById(htmlElementId);
			this.objectWidth =  el.offsetWidth;
			this.objectHeight = el.offsetHeight;
			
			this.createObject();
		}
	},
	createObject: function()
	{
		var so = new SWFObject(this.flashUrl, this.htmlElementId+"_flash", this.objectWidth, this.objectHeight, "8", "#FFFFFF");
		if(this.transparency == true)
		  so.addParam('wmode', 'transparent');
		so.write(this.htmlElementId);
		this.created = true;
	},
	getJSReady: function(){return true;},
	getImagePath: function(){return this.imagePath;},
	getImageDelay: function(){return this.imageDelay;},
	getImageHeight: function(){return this.objectHeight;},
	getImageWidth: function(){return this.objectWidth;}
});


/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

//******************************************************
// switchable content

var g_curContentDivId = -1;
var g_isAnimatingContent = 0;
var g_contentHeightTreshold = 650;      // maximum content div height in pixels
var g_contentHeaderHeight = 34;         // to resize the content only section, we must substract the header height


function adjustContentDivHeight()
{       
    if( $('middleTableRightDiv_general') == null )
    {
        return;     // no content section...
    }
    
    // fix for firefox: otherwise the height is not updated...
    $('middleTableRight').style.height = "10px";
}

function refreshVisibleContentDiv()
{
    
    var divId = getURLParam('divid');    
    if( divId )
    {
        switchContent(divId);
    }
    else
    {
        switchContent(g_firstDivId);
    }        
}

function refreshVisibleContentDivFromHref(href)
{    
    if( g_designMode ){return;}    
    
    var divId = getURLParamFromHref(href, 'divid');    
    if( divId )
    {        
        switchContent(divId);
    }
    else
    {
        switchContent(g_firstDivId);
    }           
    
    dakisBackToTop();
}


/*
    Variable: g_contentDivPrefix
    Menu item ids all have this prefix
*/
var g_contentDivPrefix = 'div_leftMenuItem_';

function switchContent(divNumber) 
{   
    
    var element = 0;    
    var index = 0;
    var closeDownNeeded = 0;
    
    if( g_isAnimatingContent == 1 )
    {
        return;     // already switching content...
    }
    
    if( divNumber == g_curContentDivId )
    {           
        return; // already visible
    }
    
    if( g_curContentDivId != -1 )
    {        
        // if the element exits, hide it
        if( $(g_contentDivPrefix+g_curContentDivId) )
        {            
            closeDownNeeded = 1;            
        }
    }    
    
    // BACKWARD compatibility: old templates don't define the g_lastDivId variable
    if( typeof g_lastDivId == "undefined")
    {   
        g_lastDivId = 40;
    }    
    
    // hide all div but the specified one.  assume a maximum number of divs.   
    for( index=0; index<=g_lastDivId; index++)
    {
        element = document.getElementById(g_contentDivPrefix+index);        
        
        if( element )
        {   
            // show this div?
            if( index == divNumber )
            {              
                // no current displayed div?            
                if( g_curContentDivId == -1 )
                {
                    // then show without animation
                    Element.show(element);
                }
                else
                {
                    if( closeDownNeeded == 1)
                    {
                     
                        if( !g_designMode )
                        {                        
                            // workaround: the queue option doesn't work properly, so use a flag instead to
                            // synchronize animations                            
                            g_isAnimatingContent = 1;                            
                            
                            executeContentEffects($(g_contentDivPrefix+g_curContentDivId), element);
                            
                            // to avoid the accordeon effect, fix the height while animating 
                            height = $('middleTableRightDiv_general').offsetHeight;
                            
                            if( height != undefined && height != null && height != 0 )
                            {
                                $('middleTableRightDiv_general').style.height = height+'px';  
                            }
                        }
                        else
                        {
                            // don't use animation while designing since this sometimes bug
                            Element.hide($(g_contentDivPrefix+g_curContentDivId));
                            Element.show(element);
                        }
                          
                        closeDownNeeded = 0;
                    }
                    else
                    {   
                        Element.show(element);
                    }
                }
                setLeftMenuSelected(index, 1);
            }
            else
            {
                // hide this div
                if( g_curContentDivId == -1 ){Element.hide(element);}
                setLeftMenuSelected(index, 0);                        
            }
        }        
    }
    
    g_curContentDivId = divNumber;        
    
}        

/*
    Function: executeContentEffects
    Execute whatever animations needed to hide old content and show new one.
    
    Override to customize the animation.  Be sure to call onContentEffectsFinished after.
*/
function executeContentEffects(oldContent, newContent)
{   
    
    new Effect.Parallel(
                        [ new Effect.BlindUp(oldContent, {}), 
                          new Effect.BlindDown(newContent, {})], 
                        {duration: 0.8, afterFinish: function() {onContentEffectsFinished();} }
                      );  
                      
}

/*
    Function: onContentEffectsFinished
    Must be called when the content transition animation is finished.
*/
function onContentEffectsFinished()
{
    g_isAnimatingContent = 0;        
    
    $('middleTableRightDiv_general').style.height = "";      
}

var g_leftMenuClassName = "menuItemText";
var g_leftMenuSelectedClassName = "selectedMenuItemText";

function setLeftMenuSelected(leftMenuId, selected)
{
    var leftMenuElement = document.getElementById('leftMenu_'+leftMenuId);
   
    var className = g_leftMenuClassName;

    if( selected ){ className = g_leftMenuSelectedClassName;}            
    
    if( leftMenuElement )
    {
        leftMenuElement.setAttribute('class', className);
        leftMenuElement.setAttribute('className', className);                
    }
}

function getURLParam(strParamName)
{
    return getURLParamFromHref(window.location.href, strParamName);            
}

function getURLParamFromHref(strHref, strParamName)
{
  var strReturn = "";          
  if ( strHref.indexOf("#") > -1 )
  {            
    var strQueryString = strHref.substr(strHref.indexOf("#")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
    {            
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 )
      {
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
} 



// *************************************************
// expandable menu

function ExpandableMenu(nbMenuItems)
{
    this.menuItemStates = new Array(nbMenuItems);       
    
    for(i=0; i<nbMenuItems; i++ )
    {
        this.menuItemStates[i] = -1;
    }
    
    this.animate = 1;
    
    this.toggleMenuItem = ExpandableMenu_toggleExpandableMenu;
    this.setMenuState = ExpandableMenu_setMenuState;
    this.collapseAll = ExpandableMenu_collapseAll;
    this.refreshMenuState = ExpandableMenu_refreshMenuState;
}

function ExpandableMenu_toggleExpandableMenu(menuIndex)
{
    this.setMenuState(menuIndex, !this.menuItemStates[menuIndex]);
}

function ExpandableMenu_collapseAll()
{
    for( i=0; i<this.menuItemStates.length; i++)
    {
        this.setMenuState(i, 0);
    }
}

function ExpandableMenu_setMenuState(menuIndex, expanded)
{
    var elementPrefix = 'expandableMenuItem_';
    var element = document.getElementById(elementPrefix+menuIndex);   
    var imgElement = document.getElementById(elementPrefix+menuIndex+'_img');   
    
    var displayStr = "";
    var imageSrc = "expandedArrow.bmp";
    
    if( !expanded )
    {
        displayStr = "none";
        imageSrc = "collapsedArrow.bmp";
        
    }
    
    if( element )
    {   
        // if first time, don't animate
        if( this.menuItemStates[menuIndex] == -1 || this.animate == 0)
        {
            element.style.display = displayStr;
        }        
        else 
        {
            if( expanded )
            {
                new Effect.OpenUp(elementPrefix+menuIndex, {duration: 0.5, queue: 'end'});
            }
            else
            {
                new Effect.CloseDown(elementPrefix+menuIndex, {duration: 0.5, queue: 'end'});                
            }
        }
        
        this.menuItemStates[menuIndex] = expanded;
        
        if( imgElement )
        {
            imgElement.setAttribute('src', imageSrc);
        }
    }

}

function ExpandableMenu_refreshMenuState()
{
    this.animate = 0;
    for( i=0; i<this.menuItemStates.length; i++)
    {
        this.setMenuState(i, this.menuItemStates[i]);
    }
    this.animate = 1;
}

// *************************************************
// Cookie management

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

// expires: in days
// path: [optional]
// domain: [optional]
// secure: bool [optional]
// example: setCookie('postalCode', 'ghgfhgf', null, null, null, null); 
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+"="+escape( value ) +
		( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// Return the document domain including the port if specified
function getDocDomain()
{   
    var domain = document.domain;
    var url = document.URL;    
    
    var domainPos = url.indexOf(domain);
    var portBeginPos = url.indexOf(":", domainPos);
    
    if( portBeginPos == -1 ){
        return domain;
    }
    
    var portEndPos = url.indexOf("/", portBeginPos);    
    
    if( portEndPos == -1 ){
        return domain;
    }
    
    domain = domain + ":" + url.substring(portBeginPos+1, portEndPos);    
    
    return domain;    
}

// Return the document domain without the page name 
function getDocDomainDir()
{
    var url = document.URL;        
    var lastSlashPos = url.lastIndexOf("/");
    
    var location = url.substring(0, lastSlashPos);    
    return location + "/";
}

// Return only the base document domain including the port.
// Don't return the subdomain.  Example: customer.mydakis.com will return dakis.com
function getBaseDocDomain()
{
    var docDomain = getDocDomain();
    
    var domains = docDomain.split(".");
    if( domains.length == 2 )
    {
        return docDomain;
    }
    
    var baseDomain = "www."+domains[domains.length-2] + "."+domains[domains.length-1];
    return baseDomain;
}

// Get the file extension without the '.' character
function dakisGetFileExtension(path)
{
    var extensionPos = path.lastIndexOf('.');
    if( extensionPos == -1 )
    {
        return "";
    }
    return path.substring(extensionPos+1);
}

// Set a file extension by replacing existing extension.
// extension - with the '.' character at the beginning if needed
function dakisSetFileExtension(path, extension)
{
    var extensionPos = path.lastIndexOf('.');
    if( extensionPos == -1 )
    {
        extensionPos = path.length;
    }
    return path.substring(0, extensionPos)+extension
    
}

// Client side cookie management
function writeJsonCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
		var expires = "";
	
	var parsedJson = $H(value).toJSON().gsub( ",", "~" );
	document.cookie = name + "=" + parsedJson + expires + "; path=/";
}

function readJsonCookie( name )
{
	var cookies = document.cookie.split(';');
	var value = null;
	
	var cookie = cookies.find( function(c){
		var nameValuePair = c.split("=");
		return nameValuePair.first().strip() == name;			
	});
	
	if( cookie != null )
	{
		var cookieValue = cookie.split("=").last();
		if( cookieValue.length > 0 )
		{
			cookieValue = cookieValue.gsub( "~", ",");
			value = cookieValue.evalJSON();
		}
	}
	
	return value;
}

function eraseCookie(name)
{
	writeJsonCookie(name,"",-1);
}


// Global variables

var g_designMode = false;
var g_dakisAdRotatorImageWidth = 60;
var g_dakisAdRotatorImageHeight = 60;
var g_dakisAdRotatorDelay = 13000;