function replaceElement(selector,color,font){
  sIFR.useStyleCheck = true;
  sIFR.fixWrap =true;
  sIFR.preserveAntiAlias =true;
  sIFR.defaultSharpness =1;
  sIFR.activate(font);
  sIFR.replace(font, {
    wmode:'opaque',
    selector: selector,
    css: {
      '.sIFR-root':{ 'color': color}
    }
  });
}

function replaceLinks(selector,color,hover,font){
  sIFR.useStyleCheck =true;
  sIFR.fixWrap =true;
  sIFR.replace(font, {
    wmode:'opaque',
    selector: selector
    ,css: [
      '.sIFR-root {}'
      ,'a { text-decoration: none }'
      ,'a:link{color: #545454}'
      ,'a:hover { color: #e86013}'
    ]
  });
}

	var optima = {
	src: 'swf/optimaRegular.swf'
	,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
	};
  if(typeof sIFR == "object"){
	replaceElement('.precontentbox h3','#EA6419',optima);
	replaceElement('.precontentbox h2','#68584D',optima);
  }


	function showStandby(){
		$('loadingGif').style.display='block';
	}
	function hideStandBy(){
		$('loadingGif').style.display='none';
	}

document.observe("dom:loaded", function() {
  $$(".clientlinks").each(function(name,index){
	name.observe("click",function(event){
		var splited=name.id.split('_');
		var url = 'portfolio.php?action=getClientdata&id='+splited[1];
		showStandby();
		new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
			var json=eval(transport);
			json=json.responseJSON;

			$('imageHolder').update('<img src="images/ajax-loading.gif" id="loadingGif" alt="" title="" /><img id="siteImage" alt="" title="" />')
				.writeAttribute('style','width:;height:;');
				showStandby();
			$('siteImage').onload=function(){
				hideStandBy();
				$("siteImage").show().appear({duration: 2.0,from:0,to:10});
			};
			$('siteImage').writeAttribute('src','thumbnails/'+json.thumbs[0].filename).hide();

			$('descBoxHandler').childElements().each(function(name,index){
				name.remove();
			});
			var str='<div class="thumbNailbox"><ul class="thumbImgList" id="thumbImgList"></ul></div><div class="contentbox"><h2 id="siteName"></h2><p class="urlLink" id="linkholder"><a id="siteUrl"></a></p><p class="webdesc" id="siteDescription"></p></div>';
			$('descBoxHandler').update('<li>'+str+'</li>');
			$('siteName').update(json.name);
			$('siteDescription').update(json.description);

			var urlArr=json.url.split('|');
			str='';
			if(urlArr.length>1){
				$('linkholder').childElements().each(function(name,index){name.remove();});
				str='<option value="">Select</option>';
				for(var i=0;i<urlArr.length;i++){
					var urlDescArr=urlArr[i].split("~");
					str+='<option value="'+urlDescArr[1]+'">'+urlDescArr[0]+'</option>';
				}
				$('linkholder').update('<select id="linkCollection">'+str+'</select>');
			}else{
				$('siteUrl').update(urlArr[0]).writeAttribute('href',urlArr[0]).writeAttribute('target','_blank');
			}

			$('thumbImgList').childElements().each(function(name,index){
				name.remove();
			});
			json.thumbs.each(function(name,index){
				$('thumbImgList').insert({bottom: '<li><img class="thumbnailImg" src="thumbnails/'+name.filename+'"></li>'});
			});
			//Rebind Listeners
			$$(".thumbnailImg").each(function(name,index){
				name.observe("click",function(event){
					$("siteImage").src=this.src;
					//$("siteImage").show().appear({duration: 2.0,from:0,to:10});
				});
			});
			if($('linkCollection')!=null){
				$('linkCollection').observe("change",function(event){
					if(this.value==''){return;}
					window.open(this.value,"NewWindow");
				});
			}
		  }
		});
	});
  });

});