

regexArr = new Array();

//regexArr['email'] = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
//regexArr['email'] = /^[a-z0-9\._-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i;
regexArr['email'] = /^[a-zA-Z0-9!#\$%&'\*\+-/=\?\^_`{\|}~\. ]+@[a-z0-9.-]+\.[a-z]{2,4}$/i
regexArr['number'] = /^[-+]?[0-9]+$/gi;
regexArr['text'] = /^[a-zA-Z0-9 ._-]+$/gi;
regexArr['textarea'] = /^[a-zA-Z0-9\n ._-]+$/gi;
regexArr['date'] = /^\d{2}\/+\d{2}\/+\d{4}$/gi;
regexArr['required'] = /[^.*]g/i;
regexArr['alpha'] = /^[a-z ._-]+$/gi;
regexArr['alphanum'] = /^[a-z0-9 ._-]+$/gi;
regexArr['digit'] = /^[-+]?[0-9]+$/gi;
regexArr['nodigit'] = /^[^0-9]+$/gi;
regexArr['number'] = /^[-+]?\d*\.?\d+$/gi;
regexArr['phone'] = /^[\d\s ().-]+$/gi;
regexArr['url'] = /^(http|https|ftp)\:\/\/[a-z0-9\-\.]+\.[a-z]{2,3}(:[a-z0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~])*$/i;


var thisURI = location.pathname;

function pageLoadFunctions(){

	signupFormActions();
	if(thisURI.substring(0,21) == '/web-design-portfolio')setMorePortfolio();
	if(thisURI.substring(0,14) == '/web-solutions')setWebSolutions();
	if(thisURI.substring(0,11) == '/contact-us' || thisURI.substring(0,8) == '/sitemap')genContactFormActions();
	
	setCssAtr();
}


function setCssAtr(){

	$("div#infobubbletransp").css("opacity","0.6");
	
	if(jQuery.support.opacity == true){
	$("div#homefeatured").children("div.c").children("div.item").children("a.imglink").mouseenter(function(){$(this).css("opacity","0.6");});
	$("div#homefeatured").children("div.c").children("div.item").children("a.imglink").mouseleave(function(){$(this).css("opacity","1");});
	}
	
	$("div#portfolioFeatured").children("div").children("div.item").children("div.c").children("div.bigimg").css({"-moz-box-shadow":"0px 0px 15px #b1b1b1",
												      "-webkit-box-shadow":"0px 0px 15px #b1b1b1",
												      "box-shadow":"0px 0px 15px #b1b1b1"});
}

function highlightMoreProjects(){

	portfolioItems = $("div.portfolioItems div.rowitems").children('div.item')

	$(portfolioItems).each(function(index){
	
		$(this).mouseenter(function(){
			
			$(this).removeClass("blank_rounded");
			$(this).addClass("content_grey_trans_rounded");
			
			showBubble($(this),'bottom','info','text','Click to view details','portfolioitem');
			//$(this).children('a.readon').attr("rel",$(this).children('a.readon').attr("title"));
			//$(this).children('a.readon').removeAttr("title");
		});
		
		$(this).mouseleave(function(){
			
			$(this).removeClass("content_grey_trans_rounded");
			$(this).addClass("blank_rounded");
			hideBubble($(this));
			//$(this).children('a.readon').attr("title",$(this).children('a.readon').attr("rel"));
			//$(this).children('a.readon').removeAttr("rel");
		});
	});
}


function setMorePortfolio(){

	highlightMoreProjects();

	$("a#moredesignwork").attr("href","#view-more-work");
	
	
	$("a#moredesignwork").click(function(e){

		e.preventDefault();
		nextStart = $("a#moredesignwork").attr("rel");

		if($(this).attr("rel") == 'complete'){
		
			movePortfolio('l');

		}else{
			
			$("div#loader").show();

			var xmlhttp;
			if (window.XMLHttpRequest)
			{
				// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp=new XMLHttpRequest();
			}
			else if (window.ActiveXObject)
			{
				// code for IE6, IE5
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			else
			{
				alert("Your browser does not support XMLHTTP!");
			}

			xmlhttp.onreadystatechange=function()
			{
				if(xmlhttp.readyState==4)
				{
					$("div#loader").hide();
					portfolioItems = xmlhttp.responseText;

					if(portfolioItems.replace(/[\s]/igm,"") != ''){
						$("a#moredesignwork").attr("rel",parseInt(nextStart)+3);
						$("div.portfolioItems div.rowitems").append(portfolioItems);
						
						jxItemCount = portfolioItems.match(/class=\"item blank/gi);
						if(jxItemCount.length < 3)$("a#moredesignwork").attr("rel","complete");

						totalItems = $("div.portfolioItems div.rowitems").children('div.item');
						itemsWidth = Math.floor(totalItems.length*298);
						$("div.portfolioItems div.rowitems").css("width",itemsWidth+"px");
					}else{
						$("a#moredesignwork").attr("rel","complete");
					}

					movePortfolio('l');
				}
			}
			
			catview = '';
			if($(this).attr("catview") && $(this).attr("catview") != '')catview = '/'+$(this).attr("catview");

			var whichChild = "/web-design-portfolio"+catview+"?tmpl=ajaxblank&layout=portfolioblank&limitstart="+nextStart;
			xmlhttp.open("GET",whichChild,true);
			xmlhttp.send(null);
		}
	});
	
	$("a#movedesignwork").attr("href","#view-more-work");
	$("a#movedesignwork").click(function(e){
	
		e.preventDefault();
		movePortfolio('r');
	});
}


function movePortfolio(tDir){

	highlightMoreProjects();

	totalItems = $("div.portfolioItems div.rowitems").children('div.item');
	
	curPos = $("div.portfolioItems div.rowitems").css("left");
	curPos = curPos.replace(/px/gi,"");
	posItems = Math.floor(curPos/298);
	posItems = posItems+3;
	
	if(tDir == 'l'){
	
		if(posItems<totalItems.length){
			$("div.portfolioItems div.rowitems").animate({"left": "+=894px"}, 300,function(){});
			if(!$("a#moredesignwork").hasClass('cmove'))$("a#moredesignwork").addClass('cmove');
			if(!$("a#movedesignwork").hasClass('cmove'))$("a#movedesignwork").addClass('cmove');
		}else{
			$("a#moredesignwork").removeClass('cmove');
		}
	}
	
	if(tDir == 'r'){
	
		if(curPos > 0){
			$("div.portfolioItems div.rowitems").animate({"left": "-=894px"}, 300,function(){});
			if(!$("a#movedesignwork").hasClass('cmove'))$("a#movedesignwork").addClass('cmove');
			if(!$("a#moredesignwork").hasClass('cmove'))$("a#moredesignwork").addClass('cmove');
		}else{
			$("a#movedesignwork").removeClass('cmove');
		}
	}
}

function setWebSolutions(){

	$("div.articlesLeading").each(function(){
	
		$(this).append('<div class="articlecontent" style="display:none;"></div>');
		
		newcontent = $(this).children("div.article-content").html();
		$(this).children("div.articlecontent").html(newcontent);
		setnewcontent =  $(this).children("div.article-content-hide").html();
		$(this).children("div.article-content").html(setnewcontent);
		
		thisTitle = $(this).children("h2").text();
		$(this).attr("title","Read more about "+thisTitle+" - click here");
		
		$(this).click(function(){
			createWebSolutions($(this));
		});
	});

}

function createWebSolutions(obj){

	$('body').append('<div id="lightboxroundbg"></div><div id="lightboxroundcont"><div id="lightboxround"></div></div><a href="#close" id="lightboxroundclose"></a>');
	
	$("div#lightboxroundbg").click(function(){
	
		removeWebSolutions(obj);
	});
	
	$("a#lightboxroundclose").click(function(e){
	
		e.preventDefault();
		removeWebSolutions(obj);
	});
	
	$("div#lightboxround").html($(obj).html());
	$("div#lightboxround").children("div.article-content").remove();
	$("div#lightboxround").children("div.article-content-end").remove();
	$("div#lightboxround").children("div.article-content-hide").remove();
	$("div#lightboxround").children("div.articlecontent").css("display","");
	
	objPosition = $(obj).offset();
	
	$("div#lightboxroundcont").css({'top':objPosition.top+'px','left':objPosition.left+'px','margin':'0'});
	
	$("div#lightboxroundbg").fadeTo(0,0.2,function(){
	
		popwidth = $('body').outerWidth();
		popwidth = Math.floor((parseInt(popwidth)-891)/2);
		
		popheight = $('div#lightboxroundbg').outerHeight();
		popheight = Math.floor((parseInt(popheight)-338)/2);
		poppos = $(window).scrollTop();
		popheight = parseInt(popheight)+parseInt(poppos);
		
		closeleft = popwidth+941;
		closetop = popheight;
		
		$("a#lightboxroundclose").css({'position':'absolute','top':closetop+'px','left':closeleft+'px','margin':'0'});
		
		$("div#lightboxroundcont").show();
		$("div#lightboxroundcont").animate({
		    top:popheight+'px',
		    left:popwidth+'px',
		    width:'891px',
		    height:'338px'
		  }, 200, function() {
		    $("div#lightboxround").show();
		    $("a#lightboxroundclose").show();
		  });
	});
}

function removeWebSolutions(obj){
	
	objPosition = $(obj).offset();
	
	$("a#lightboxroundclose").remove();
	$("div#lightboxroundcont").html("");
	
	$("div#lightboxroundcont").animate({
	    top:objPosition.top+'px',
	    left:objPosition.left+'px',
	    width:'390px',
	    height:'90px'
	  }, 200, function() {
		$("div#lightboxroundcont").remove();
		$("div#lightboxroundbg").remove();
	  });
}

function signupFormActions(){

	textInputs = $("form#newsletterSignup").children('div.text-input').children('input');
	
	$(textInputs).each(function(index){
		
		$(this).focus(function(){
			
			$(this).css('background-position','left bottom');
			$(this).parent().css('background-position','right bottom');
		});
		
		$(this).blur(function(){
		
			$(this).css('background-position','left top');
			$(this).parent().css('background-position','right top');
		});
	});

	
	$("input#newsletterSignup-FNAME").focus(function(){
		
		nameObj = $(this);
		if(nameObj.val() == 'Forename'){nameObj.val('');}
		hideBubble(nameObj);
	});
	
	$("input#newsletterSignup-FNAME").blur(function(){
	
		nameObj = $(this);
		nameVal = nameObj.val().replace(/ /gi,"");
		if((regexArr['text']) && (regexArr['text'].test(nameVal) == false)){
		
			showBubble(nameObj,'top','info','library','required','false');
		}
	});
	
	$("input#newsletterSignup-LNAME").focus(function(){
		
		nameObj = $(this);
		if(nameObj.val() == 'Surname'){nameObj.val('');}
		hideBubble(nameObj);
	});
	
	$("input#newsletterSignup-LNAME").blur(function(){
	
		nameObj = $(this);
		nameVal = nameObj.val().replace(/ /gi,"");
		if((regexArr['text']) && (regexArr['text'].test(nameVal) == false)){
		
			showBubble(nameObj,'top','info','library','required','false');
		}
	});
	
	$("input#newsletterSignup-email").focus(function(){
		
		emailObj = $(this);
		if(emailObj.val() == 'Email'){emailObj.val('');}
		hideBubble(emailObj);
	});
	
	$("input#newsletterSignup-email").blur(function(){
	
		emailObj = $(this);
		if((regexArr['email']) && (regexArr['email'].test(emailObj.val()) == false)){
		
			showBubble(emailObj,'right','info','library','email','false');
		}
	});
	
	$("form#newsletterSignup").submit(function() {
		
		return validateForm('newsletterSignup','0',false,'right,info,library');
	});
}

function checknewsletterfocus(){

		if($("form#newsletterSignup").attr("sentsuccess") == 'true'){
		
			$("input#newsletterSignup-FNAME").val("Forename");
			$("input#newsletterSignup-LNAME").val("Surname");
			$("input#newsletterSignup-email").val("Email");
			
			$("form#newsletterSignup").attr("sentsuccess","");
		}
}

function genContactFormActions(){

	$("input#generalContact-email").focus(function(){
		
		hideBubble($(this));
	});
	
	$("input#generalContact-full-name").focus(function(){
		
		hideBubble($(this));
	});
	
	$("textarea#generalContact-message").focus(function(){
		
		hideBubble($(this));
	});

	$("form#generalContact").submit(function() {
		
		return validateForm('generalContact','1',false,'left,info,library');
	});
}

function infobubbleLibrary(contentSelect){

	var contentTxt = 'ERROR';
	var contentArr = new Array();
	
	contentArr['text'] = 'This field is required!';
	contentArr['email'] = 'Valid Email Required<br />e.g. valid@emailaddress.com';
	//contentArr['textarea'] = 'Invalid Characters<br />Valid: a-z A-Z 0-9 - _ .';
	contentArr['textarea'] = 'This field is required!';
	contentArr['required'] = 'This field is required!';
	
	if(contentArr[contentSelect])contentTxt = contentArr[contentSelect];
	return contentTxt;
}


function showBubble(obj,objPos,bType,contentFrom,contentSelect,extrastyle){

	pageCoords = obj.offset();
	objLeft = pageCoords.left;
	objTop = pageCoords.top;
	
	objWidth = obj.outerWidth();
	objHeight = obj.outerHeight();
	
	objId = obj.attr("id");
	objId = objId+'-infobubble';

	objAdjCss = false;
	objClass = 'infobubble';
	if(extrastyle != 'false'){
		if(extrastyle == 'portfolioitem'){objClass = objClass+' '+extrastyle;objAdjCss = true;}
	}
	if(bType == 'error')objClass = objClass+' errorbubble';
	
	
	objContent = '';
	if(contentFrom == 'library'){objContent = infobubbleLibrary(contentSelect);}
	else if(contentFrom == 'text'){
	
		contentSelect = contentSelect.replace(/&gt;/g,">");
		contentSelect = contentSelect.replace(/&lt;/g,"<");
		objContent = contentSelect;
	}
	
	objArClass = 'avb';
	if(objPos == 'right')objArClass = 'ahr';
	if(objPos == 'top')objArClass = 'avt';
	if(objPos == 'left')objArClass = 'ahl';
	if(objPos == 'none')objArClass = 'ahvn';
	
	$('body').append('<div class="'+objClass+'" id="'+objId+'"><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div><div class="'+objArClass+'"></div><div class="c"></div><div class="cs"></div></div>');

	$('#'+objId+' .cs').click(function(){hideBubble(obj)});
	$('#'+objId+' .c').html(objContent);
	
	infoBubbleWidth = $('#'+objId).outerWidth(true);
	infoBubbleHeight = $('#'+objId).outerHeight(true);
	
	thisObjWidth = 'auto';

	if(objPos == 'left'){
	
		thisObjTop = Math.floor(objTop)+'px';
		thisObjLeft = Math.floor(parseInt(objLeft)-parseInt(infoBubbleWidth))+'px';
		thisMargin = '8px 15px 8px 0';
		
		if(Math.floor(parseInt(objLeft)-parseInt(infoBubbleWidth)) < 0){
			
			thisObjLeft = '10px';
			thisObjWidth = Math.floor(parseInt(infoBubbleWidth)-parseInt(objLeft));
			thisObjWidth = thisObjWidth+10;
			thisObjWidth = Math.floor(parseInt(infoBubbleWidth)-parseInt(thisObjWidth))+'px';
		}

		if($(obj).parent('div').attr("class") == 'text-input'){
		
			thisObjLeft = Math.floor((parseInt(objLeft)-parseInt(infoBubbleWidth))-12)+'px';
		}
		
	}else if(objPos == 'right'){
	
		thisObjTop = Math.floor(objTop)+'px';
		thisObjLeft = Math.floor(parseInt(objLeft)+parseInt(objWidth))+'px';
		thisMargin = '8px 0 8px 15px';
	
	}else if(objPos == 'top'){
		
		thisObjTop = Math.floor(parseInt(objTop)-parseInt(infoBubbleHeight))+'px';
		thisObjLeft = Math.floor(objLeft)+'px';
		thisMargin = '8px 0 22px 0';
	
	}else if(objPos == 'bottom'){
	
		thisObjTop = Math.floor(parseInt(objTop)+parseInt(objHeight))+'px';
		if(objAdjCss == true)thisObjTop = Math.floor(parseInt(objTop)+parseInt(objHeight)-12)+'px';
		thisObjLeft = Math.floor(objLeft)+'px';
		thisMargin = '22px 0 8px 0';
	
	}else{
	
		thisObjTop = Math.floor(parseInt(infoBubbleHeight)/2)+'px';
		thisObjLeft = Math.floor(parseInt(infoBubbleWidth)/2)+'px';
		thisMargin = '-'+thisObjTop+' 0 0 -'+thisObjLeft;
		thisObjTop = "50%";
		thisObjLeft = "50%";
		thisObjWidth = infoBubbleWidth;
		
		$('#'+objId).css('position','fixed');
		$('body').append('<div id="infobubbletransp"></div>');
		
		$("div#infobubbletransp").css("opacity","0.6");
	}
	
	
	$('#'+objId).css({
		'top':thisObjTop,
		'left':thisObjLeft,
		'margin':thisMargin,
		'width':thisObjWidth,
		'display':'block'
	});

}


function hideBubble(obj){

	objId = obj.attr("id");
	objId = objId+'-infobubble';
	
	$('#'+objId).remove();
	$('div#infobubbletransp').remove();
}


var formFieldName = new Array();
var formFieldLabel = new Array();
var formFieldType = new Array();
var formFieldClean = new Array();

function validateForm(formname,showErrorMssg,showErrorStyle,infoBubbleAr){

	showInfoBubble=false;
	infoBubbleAtt = infoBubbleAr.split(',');
	
	if(infoBubbleAtt.length == 3)showInfoBubble=true;
	var filterNames = /^(Name|Forename|Surname|Email)$/i;

	
	var totalFields = formFieldName[formname].length;
	
	var equalExtras = 0;
	if(formFieldType[formname].length == totalFields)equalExtras = equalExtras+1;
	if(formFieldClean[formname].length == totalFields)equalExtras = equalExtras+1;
	if(formFieldLabel[formname].length == totalFields)equalExtras = equalExtras+1;

	
	if(formFieldName[formname].length > 0 && equalExtras == 3)
	{
		chkDetails = new Array();
		chkDetails['num'] = 0;
		chkDetails['mssg'] = 'Please fill in all required fields.<br /><br />';

		for(i=0;i<formFieldName[formname].length;i++)
		{
			fieldname = formFieldName[formname][i];
			fieldlabel = formFieldLabel[formname][i].replace(/-/g," ");
			
			if(formFieldType[formname][i] == 'text' || formFieldType[formname][i] == 'textarea')
			{
				fieldobj = $("#"+formname+"-"+fieldname);
				fieldval = $(fieldobj).val();
				
				fieldvalChk = fieldval.replace(/ /gi,"");
				
				/*
				fieldregChk=true;
				if((regexArr[formFieldClean[formname][i]]) && (regexArr[formFieldClean[formname][i]].test(fieldvalChk) == false))fieldregChk = false;
				*/
				
				fieldregChk=false;
				
				if(regexArr[formFieldClean[formname][i]]){
				
					if(formname == 'email' && regexArr[formFieldClean[formname][i]].test(fieldvalChk) == false){

						fieldvalChk = '';

					}else{ 

						fieldregChk = true;
						//fieldvalChk = fieldvalChk.replace(regexArr[formFieldClean[formname][i]],"");
					}
				}
				
				if(formFieldClean[formname][i] == 'textarea')fieldregChk = true;
				
				if(fieldvalChk != "" && fieldregChk == true && !filterNames.test(fieldvalChk))
				{
					chkDetails['num'] = chkDetails['num']+1;
					if(showErrorStyle == true)$(fieldobj).css('border','');
				}
				else
				{
					chkDetails['mssg'] += "- "+fieldlabel+"<br />";
					if(showErrorStyle == true)$(fieldobj).css('border','1px solid #a32323');
					if(showInfoBubble == true)showBubble($(fieldobj),infoBubbleAtt[0],infoBubbleAtt[1],infoBubbleAtt[2],formFieldClean[formname][i],'false');
				}
				
			}

		}

		if(chkDetails['num'] == formFieldName[formname].length)
		{
			$("form#"+formname).attr("sentsuccess","true");
			if(showErrorMssg==0)var newslettertime = setTimeout("checknewsletterfocus()",2000);
			
			return true;
			
		}
		else
		{
			/***************
			* showErrorMssg = 1 | no error display 
			* showErrorMssg = 2 | inline html error display 
			* showErrorMssg = 3 | js pop-up error display 
			* showErrorMssg = 4 | js alert error display 
			***************/
			
			formErrObj = '.formerrorcont'+formname;
			
			if(showErrorMssg == 2){
				
				$(formErrObj).html(chkDetails['mssg']);
				$(formErrObj).css('display','block');
				
				var errorOffset = $(formErrObj).offset();
				var errorOffsetY = errorOffset.top-100;
				
				$('html,body').animate({scrollTop: errorOffsetY}, "slow");


			}else if(showErrorMssg == 4){
			
				chkDetails['mssg'] = chkDetails['mssg'].replace(/<br \/>/gi,"\n");
				alert(chkDetails['mssg']);
			
			}
				
			return false;
		}
	}
}


function sendFormAlert(warningType){

	if(warningType == 'fail')alert("Form Failed!");
	if(warningType == 'success')alert("Form Complete and Sent!");
	if(warningType == 'alreadysent')alert("Error: Form Already Sent!");
}

/** creates an extra stylesheet **/
function addstyles(){

	//** Build js rendered stylesheet that css validators fail on **
	var jstyle = document.getElementsByTagName("head")[0];
	var lk = document.createElement("link");
	jstyle.appendChild(lk);
	lk.setAttribute("rel", "stylesheet");
	lk.setAttribute("type", "text/css");
	lk.setAttribute("href", "/js-vl.css");
}


function startImgSlide(){

	slideImgCont = $('#contentright > #rightphotos > div');
	slideImgs = $(slideImgCont).children('img');

	if(slideImgs.length > 1){

		$(slideImgCont).append('<div id="loadingo"></div>');
		
		var loaded=0;
		var imgload = new Array();
		for(i=0;i<slideImgs.length;i++){
		
			$(slideImgs[i]).css("z-index",i);
			
			imgload[i] = new Image();
			imgload[i].onload = function(){loaded++;imgsLoaded(loaded,slideImgs.length);}
			imgload[i].src = $(slideImgs[i]).attr("src");
		}
		
	}else{
	
		$('#contentright > #rightphotos > div').children('img').css("left","0");
	}
}


function imgsLoaded(img,totalimg){

	slideImgCont = $('#contentright > #rightphotos > div');
	slideImgs = $(slideImgCont).children('img');
	
	if(img == totalimg){
	
		$('div#loadingo').remove();
		
		slideImages('1',4000);
		$(slideImgs[0]).css("right","0px");
	}
}

function slideImages(img,timer){

	thisImgTime = setTimeout(function(){
		slideImgCont = $('#contentright > #rightphotos > div');
		slideImgs = $(slideImgCont).children('img');

		if(img>=slideImgs.length)img=0;

		preImg = parseInt(img)-1;
		if(preImg<0)preImg=slideImgs.length-1;

		newIndex = $(slideImgs[preImg]).css("z-index");
		newIndex = parseInt(newIndex)+1;
		
		$(slideImgs[preImg]).animate({"right": "419px"}, 1500,function() {$(slideImgs[preImg]).css("right","-419px");});
		

		$(slideImgs[img]).css("z-index",newIndex);
		$(slideImgs[img]).animate({"right": "0px"}, 1500,function() {img++;slideImages(img,4000)});
	},timer);
}


function contentPrinter(id,article,cwidth,cheight){

	myWindow = window.open('/contentPrinter.html','_blank','width=700,height=540,resizable=yes,scrollbars=yes,toolbar=yes');
	myWindow.focus();
	xtContent = '';
	myWindow.vcdlID = id;
	myWindow.articleNumber = article;
	myWindow.articles = $("div."+id);
	myWindow.xtrContent = xtContent;
	myWindow.printContent = true;
}


function blankPage(rType,rLocation){

	xtContent = '';
	
	if(rType == 'video'){
	
		xtContent += '<object id="VIDEO" width="640" height="360" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">';
		xtContent += '<param name="URL" value="'+rLocation+'">';
		xtContent += '<param name="play" value="false">';
		xtContent += '<param name="quality" value="best" />';
		xtContent += '<embed src="'+rLocation+'" play="false" quality="best" bgcolor="#ffffff" width="640" height="360" name="movie" align="middle" allowScriptAccess="sameDomain" type="application/x-oleobject"></embed>';
		xtContent += '</object>';
	}
	
	myWindow = window.open('/contentPrinter.html','_blank','width=700,height=540,resizable=yes,scrollbars=yes,toolbar=yes');
	myWindow.focus();
	myWindow.vcdlID = '0';
	myWindow.articleNumber = '0';
	myWindow.articles = false;
	myWindow.xtrContent = xtContent;
	myWindow.printContent = false;
}



//######## JS script for Joomla template##########
var siteurl = '';

function fixIEPNG(el, bgimgdf, sizingMethod, type, offset){
	var objs = el;
	if(!objs) return;
	if ($type(objs) != 'array') objs = [objs];
	if(!sizingMethod) sizingMethod = 'crop';
	if(!offset) offset = 0;
	var blankimg = siteurl + 'images/blank.png';
	objs.each(function(obj) {
		var bgimg = bgimgdf;
		if (obj.tagName == 'IMG') {
			//This is an image
			if (!bgimg) bgimg = obj.src;
			if (!(/\.png$/i).test(bgimg) || (/blank\.png$/i).test(bgimg)) return;

			obj.setStyle('height',obj.offsetHeight);
			obj.setStyle('width',obj.offsetWidth);
			obj.src = blankimg;
			obj.setStyle ('visibility', 'visible');
			obj.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
		}else{
			//Background
			if (!bgimg) bgimg = obj.getStyle('backgroundImage');
			var pattern = new RegExp('url\s*[\(\"\']*([^\'\"\)]*)[\'\"\)]*');
			if ((m = pattern.exec(bgimg))) bgimg = m[1];
			if (!(/\.png$/i).test(bgimg) || (/blank\.png$/i).test(bgimg)) return;
			if (!type)
			{
				obj.setStyle('background', 'none');
				//if(!obj.getStyle('position'))
				if(obj.getStyle('position')!='absolute' && obj.getStyle('position')!='relative') {
					obj.setStyle('position', 'relative');
				}

				//Get all child
				var childnodes = obj.childNodes;
				for(var j=0;j<childnodes.length;j++){
					if((child = $(childnodes[j]))) {
						if(child.getStyle('position')!='absolute' && child.getStyle('position')!='relative') {
							child.setStyle('position', 'relative');
						}
						child.setStyle('z-index',2);
					}
				}
				//Create background layer:
				var bgdiv = new Element('IMG');
				bgdiv.src = blankimg;
				bgdiv.width = obj.offsetWidth - offset;
				bgdiv.height = obj.offsetHeight - offset;
				bgdiv.setStyles({
					'position': 'absolute',
					'top': 0,
					'left': 0
				});

				bgdiv.className = 'TransBG';

				bgdiv.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
				bgdiv.inject(obj, 'top');
				//alert(obj.innerHTML + '\n' + bgdiv.innerHTML);
			} else {
				obj.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
			}
		}
	}.bind(this));

}

function switchFontSize(ckname,val){
	var bd = $('body');
	switch (val) {
		case 'inc':
			if (CurrentFontSize+1 < 7) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize++;
				bd.addClass('fs'+CurrentFontSize);
			}
		break;
		case 'dec':
			if (CurrentFontSize-1 > 0) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize--;
				bd.addClass('fs'+CurrentFontSize);
			}
		break;
		default:
			bd.removeClass('fs'+CurrentFontSize);
			CurrentFontSize = val;
			bd.addClass('fs'+CurrentFontSize);
	}
	$.cookie(ckname, CurrentFontSize,{expires:365});
}
