var DHTML_SUITE_THEME_FOLDER = "includes/dhtml-suite-batur/themes/";
var DHTML_SUITE_THEME = 'blue';

function funInclude(txtFile)
{
	document.write('<'+'script');
	document.write(' language="javascript"');
	document.write(' type="text/javascript"');
	document.write(' src="'+txtFile+'">');
	document.write('</'+'script'+'>');
}

funInclude('includes/dhtml-suite-batur/js/ajax.js');
funInclude('includes/dhtml-suite-batur/js/separateFiles/dhtmlSuite-common.js');
funInclude('includes/dhtml-suite-batur/js/separateFiles/dhtmlSuite-imageEnlarger.js');
funInclude('includes/dhtml-suite-batur/js/separateFiles/dhtmlSuite-dynamicContent.js');
funInclude('includes/dhtml-suite-batur/js/separateFiles/dhtmlSuite-modalMessage.js');

var enlargerObj = '';

OldOnLoad = function() {};
if (typeof(window.onload) == 'function')
	OldOnLoad = window.onload;
window.onload=function() {
	OldOnLoad();
	try
	{
		funPerPageLoad();
	}
	catch(err)
	{
	}
	
	enlargerObj = new DHTMLSuite.imageEnlarger();
	preloader();
	
	messageObj = new DHTMLSuite.modalMessage();
	messageObj.setWaitMessage('Loading ....');
	messageObj.setShadowOffset(5);	// Large shadow

	DHTMLSuite.commonObj.setCssCacheStatus(false);
}

var intProductImage = 0;

function funProductImageSwap(num)
{
	var divRef1 = document.getElementById('product-image-'+num);
	var divRefThumb1 = document.getElementById('product-thumb-'+num);
	var divRef2 = document.getElementById('product-image-'+intProductImage);
	var divRefThumb2 = document.getElementById('product-thumb-'+intProductImage);
	
	divRef1.style.display = '';
	divRefThumb1.style.display = 'none';
	divRef2.style.display = 'none';
	divRefThumb2.style.display = 'inline';
	
	intProductImage = num;
}

function funProductImageLarge(imagePath,title,description)
{
	enlargerObj.displayImage(imagePath,title,description);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var OptionWindow = window.open(theURL,winName,features);
  OptionWindow.focus();
}

function funShowGallery()
{
	var divRef = document.getElementById('gallery-area-backing');
	var divRef2 = document.getElementById('gallery-area');
	
	divRef.style.opacity = 0;
    divRef.style.MozOpacity = 0;
    divRef.style.filter = "alpha(opacity=0)";
    divRef.style.display = '';
    divRef.style.position = 'absolute';
    divRef.style.top = 0+'px';
    divRef.style.left = 0+'px';
    divRef.style.zIndex = 90000;
    divRef.style.width = funGetBrowserWidth() + 'px';
    if (document.body.clientHeight + 50 < funGetBrowserHeight)
    	divRef.style.height = document.body.clientHeight + 50 + 'px';
    else
    	divRef.style.height = '3000px';
    
    divRef2.style.zIndex = 90001;
    divRef2.style.display = '';
    funPositionCenter(divRef2.id);
   	divRef2.style.display = 'none';
    
   	funFadeIn('gallery-area-backing',0,5,10,'document.getElementById(\'gallery-area\').style.display=""; funPositionCenter(\'gallery-area\');');
}

function funHideGallery()
{
	var divRef = document.getElementById('gallery-area-backing');
	var divRef2 = document.getElementById('gallery-area');
	divRef.style.opacity = 1;
    divRef.style.MozOpacity = 1;
    divRef.style.filter = "alpha(opacity=100)";
    divRef.style.display = '';
    divRef.style.position = 'absolute';
    divRef.style.top = 0+'px';
    divRef.style.left = 0+'px';
    divRef.style.zIndex = 100000;
    divRef.style.width = funGetBrowserWidth() + 'px';
    divRef.style.height = document.body.clientHeight + 50 + 'px';
    
    divRef2.style.zIndex = 100001;
    divRef2.style.display = 'none';
    
   	funFadeOut('gallery-area-backing',80,5,10,'document.getElementById(\'gallery-area-backing\').style.display="none";');
}

function funFadeIn(id,opacity,fadeStep,fadeSpeed,callOnFinish)
{
	var i = 0;
	var a = 0;
	var multiplier = (document.all ? 2 : 1);
	
	var divRef = document.getElementById(id);
	callOnFinish = unescape(callOnFinish);
	
	divRef.style.opacity = (opacity / 100);
    divRef.style.MozOpacity = (opacity / 100);
    divRef.style.filter = "alpha(opacity=" + opacity + ")";
    
    opacity += (fadeStep * multiplier);
	
	if (opacity >= 100)
	{
		divRef.style.opacity = (opacity / 100);
	    divRef.style.MozOpacity = (opacity / 100);
	    divRef.style.filter = "alpha(opacity=" + opacity + ")";
		if (callOnFinish)
			eval(callOnFinish);
	}
	else
	{
		setTimeout('funFadeIn(\'' + id + '\','+ opacity +','+fadeStep+','+fadeSpeed+',\''+escape(callOnFinish)+'\')',(fadeSpeed / multiplier));
	}
}

function funFadeOut(id,opacity,fadeStep,fadeSpeed,callOnFinish)
{
	var i = 0;
	var a = 0;
	var multiplier = (document.all ? 2 : 1);
	
	var divRef = document.getElementById(id);
	callOnFinish = unescape(callOnFinish);
	
	divRef.style.opacity = (opacity / 100);
    divRef.style.MozOpacity = (opacity / 100);
    divRef.style.filter = "alpha(opacity=" + opacity + ")";
    
    opacity -= (fadeStep * multiplier);
	
	if (opacity <= 1)
	{
		if (callOnFinish)
			eval(callOnFinish);
	}
	else
	{
		setTimeout('funFadeOut(\'' + id + '\','+ opacity +','+fadeStep+','+fadeSpeed+',\''+escape(callOnFinish)+'\')',(fadeSpeed / multiplier));
	}
}

function funGetBrowserWidth()
{
	if(self.innerWidth)
		return self.innerWidth;
	
	return document.documentElement.offsetWidth;
}
	
function funGetBrowserHeight()
{
	if(self.innerHeight)
		return self.innerHeight;
	
	return document.documentElement.offsetHeight;
}

function funPositionCenter(id)
{
	var divRef = document.getElementById(id);
	
	divRef.style.position = 'absolute';
	
	var browserHeight = funGetBrowserHeight();
	var browserWidth = funGetBrowserWidth();
	var browserOffsetTop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	
	intTop = ((browserHeight - divRef.offsetHeight)/2)+browserOffsetTop;
	if (intTop < 0)
		intTop=0;
	if (browserOffsetTop > intTop)
		intTop = browserOffsetTop;
	
	intLeft = ((browserWidth - divRef.offsetWidth)/2);
	if (intLeft < 0)
		intLeft=0;
	
	divRef.style.top = intTop+'px';
	divRef.style.left =  intLeft+ 'px';
}

function preloader() 
{
     // counter
     var i = 0;

     // create object
     imageObj = new Array;

	 
	 // set image list
    images = new Array();
	//images[0]="images/add-basket-button-over.jpg"
	
	 
     // start preloading
     for(i=0; i<images.length; i++) 
     {
     	  imageObj[i] = new Image();
          imageObj[i].src=images[i];
     }
} 

window.onresize = function() {
	if (document.getElementById('gallery-area-backing'))
	{
		if (document.getElementById('gallery-area').style.display == '')
		{
			var divRef = document.getElementById('gallery-area-backing');
		
			divRef.style.position = 'absolute';
	    	divRef.style.top = 0+'px';
		    divRef.style.left = 0+'px';
	    	divRef.style.width = funGetBrowserWidth() + 'px';
		    divRef.style.height = document.body.clientHeight + 50 + 'px';
		    
	    	funPositionCenter('gallery-area');
		}
	}
}

function displayMessage(url)
{	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(500,300);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function closeMessage()
{
	messageObj.close();	
}

function funURLEncode(txtValue)
{
	txtValue = encodeURI(txtValue);
	txtValue = txtValue.replace(/%C2%A3/g,'%A3');
	txtValue = txtValue.replace(/&/g,'%26');
	txtValue = txtValue.replace(/=/g,'%3D');
	txtValue = txtValue.replace(/\?/g,'%3F');
	
	return txtValue;
}