 
    function ShowColorOption()
    {
        if(document.getElementById('divcolor').style.display == 'inline')
        {
            document.getElementById('divcolor').style.display = 'none';
            document.getElementById('divnocolor').style.display = 'inline';
        }
        else
        {
            document.getElementById('divcolor').style.display = 'inline';
            document.getElementById('divnocolor').style.display = 'none';
        } 
        return false;
    }
    
    
    
    
    var imgIndexes = 0;
    function setIsLeft(st)
    {           
            if(st == 't' && imgIndexes <4)
            {                        
                var hexVal;
                if(BrowserDetect.browser)
                    {
                        if(BrowserDetect.browser == "Opera") 
                        {
                           hexVal = cutHex($('body').css('background-color'));   
                        }
                        else if(BrowserDetect.browser != "Explorer")
                        {    
                             hexVal = rgbConvert(cutHex($('body').css('background-color')));   
                        }
                        else
                        {   
                           hexVal = cutHex($('body').css('background-color'));   
                        }   
                   }
                             
               
                 var RedVal;                  
                 var GreenVal;
                 var BlueVal;
                       
               RedVal = HexToR(hexVal);
               GreenVal = HexToG(hexVal);
               BlueVal = HexToB(hexVal);               

                      
               
               var col =  RGBtoHex(RedVal+10,GreenVal+10,BlueVal+10);
               col = '#'+col;
                    
                //8A9199                         
                //  $('#boxDivColor').css('background-color',col);
                //  $('body').css('background-color',col);
               changecolor(col,1);
                var leftCalc =  document.getElementById('ColorSlideMove').style.left.replace('px','');       
                leftCalc = parseFloat(leftCalc);
                leftCalc +=2;        
                leftCalc = leftCalc + 'px';                                
                document.getElementById('ColorSlideMove').style.left = leftCalc;
                imgIndexes ++; 
               }
             else if( st == 'f' && imgIndexes > -4)
             {  
             
              var hexVal;
                
                if(BrowserDetect.browser)
                    {
                        if(BrowserDetect.browser == "Opera")
                        {   
                           hexVal = cutHex($('body').css('background-color'));   
                        }
                        else if(BrowserDetect.browser != "Explorer")
                        {    
                             hexVal = rgbConvert(cutHex($('body').css('background-color')));   
                        }
                        else
                        {   
                           hexVal = cutHex($('body').css('background-color'));   
                        }   
                   }
             
                       
               var RedVal = HexToR(hexVal);
               var GreenVal = HexToG(hexVal);
               var BlueVal = HexToB(hexVal);
               
               var col =  RGBtoHex(RedVal-10,GreenVal-10,BlueVal-10);
               col = '#'+col;
              
                // $('#boxDivColor').css('background-color',col);
                // $('body').css('background-color',col);
                changecolor(col,1);
                
                var leftCalc =  document.getElementById('ColorSlideMove').style.left.replace('px','');       
                leftCalc = parseFloat(leftCalc);
                leftCalc -=2;        
                leftCalc = leftCalc + 'px';
                document.getElementById('ColorSlideMove').style.left = leftCalc;
                imgIndexes --; 
             }            
             
            
    }
    
    
    
 var positionElement1 = getAbsolutePosition1(document.getElementById('imgBar'));   
    
    function changecolor(color,isNotOrignal)
    {
 try
   {
    
        imgIndexes = 0;
      //  document.getElementById('ColorSlideMove').style.left = positionElement1.x +100+ 'px';
        
        //document.getElementById('boxDivColor').style.background = color;
        
        $('#boxDivColor').css('background-color',color);
         $('body').css('background-color',color);
              
        //document.body.style.backgroundColor=color;              
        createCookie('bgcolor',color,30);
        document.getElementById('boxDivColor').style.background = color;
       
        if(isNotOrignal == 0)
      {        
                
             document.getElementById('ColorSlideMove').style.left = positionElement1.x +70+ 'px';
			
      }
        
        }
        catch(e){}
       
    }
    
    
    function createCookie(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 = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
changecolor(readCookie('bgcolor'),1);


//---------- COLOR Saturation Code -----------------//


function HexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function HexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function HexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}



function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}



function getAbsolutePosition1(element){
    var ret = new Point1();
    for(; 
        element && element != document.body;
        ret.translate(element.offsetLeft, element.offsetTop), element = element.offsetParent
        );
        
    return ret;
}

function Point1(x,y){
        this.x = x || 0;
        this.y = y || 0;
        this.toString = function(){
            return '('+this.x+', '+this.y+')';
        };
        this.translate = function(dx, dy){
            this.x += dx || 0;
            this.y += dy || 0;
        };
        this.getX = function(){ return this.x; }
        this.getY = function(){ return this.y; }
        this.equals = function(anotherpoint){
            return anotherpoint.x == this.x && anotherpoint.y == this.y;
        };
}


function rgbConvert(str) {   str = str.replace(/rgb\(|\)/g, "").split(",");   str[0] = parseInt(str[0], 10).toString(16).toLowerCase();   str[1] = parseInt(str[1], 10).toString(16).toLowerCase();   str[2] = parseInt(str[2], 10).toString(16).toLowerCase();   str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];   str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];   str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];   return (str.join(""));}



    
       
   document.getElementById('ColorSlideMove').style.position = 'absolute';
   document.getElementById('ColorSlideMove').style.top = positionElement1.y +65+ 'px';
   document.getElementById('ColorSlideMove').style.left = positionElement1.x +70+ 'px';

//---------- COLOR Saturation Code -----------------//

var ColorHoverCheck = 0;
var alertTimerId;
$('#C_Picker_Div').mouseenter
(
function()
    {   
        //alert('divHover');
 
        clearTimeout(alertTimerId);
        ColorHoverCheck = 1;
    }
)

$('#C_Picker_Div').mouseleave
(
function()
    {  
        
        ColorHoverCheck = 0;      
        
       alertTimerId = setTimeout("hideColorDiv()",1000); 
        
    }
)

function hideColorDiv()
{
    if(ColorHoverCheck == 0)
    { 
          // $('#C_Picker_Div').css('display','none');      
           $('#C_Picker_Div').animate({opacity:'hide'},500);              
      }
}


$('#C_Picker_tag').click(function(){

        clearTimeout(alertTimerId);            
})

$('#C_Picker_tag').mouseleave
(
    function()
    {
     
    alertTimerId =  setTimeout("hideColorDiv()",1000);

	}
)



/********************************** Browser Detection Script ****************************/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 	
			// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
 