function confirmLink(theLink, msg) { //v1.0
	cmsg = 'Do you want to ' + msg;
  	var is_confirmed = confirm(cmsg);
   	if (is_confirmed) {
   		theLink.href += '&confirmed=1';
   	}
   	return is_confirmed;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function contact() {
	w=500;
	h=666;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	contactInfoWindow=window.open('/contact.php','contact',settings);
	contactInfoWindow.focus();
	
}
function pageInfo(id) {
	var path;
	path='/admin/page.php?ID=' + id;
	pageInfoWindow=window.open(path,'pageInfo','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=630,height=800');
	pageInfoWindow.focus();
}

function memberInfo(id,action, bid) {
	w=850;
	h=800;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
	var path;
	path='/admin/member.php?ID=' + id + '&action='+action;
	if (bid!=null) {
		path=path+'&bID='+bid;
	}
	memberWindow=window.open(path,'memberInfo',settings);
	memberWindow.focus();
}


function assignmentsInfo(id) {
	w=850;
	h=800;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
	var path;
	path='/admin/classroom-assignments.php?ID=' + id;
	uploadImageWindow=window.open(path,'assignmentInfo',settings);
	uploadImageWindow.focus();
}

function uploadImage(dir) {
	w=584;
	h=130;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	var path;
	path='/admin/upload.php?dir=' + dir;
	uploadImageWindow=window.open(path,'uploadImage',settings);
	uploadImageWindow.focus();
}
function showInterests(int) {
	var path;
	path='/admin/interests_window.php?int=' + int;
	interestsInfoWindow=window.open(path,'interestsInfo','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=645,height=250');
	interestsInfoWindow.focus();
}
function shareThis(thelink){
	var url=location.href.replace("&", "-amp-");
	url=location.href.replace("?", "-que-");
	var title=document.title;
	thelink.href='/popups.php?action=sharethis&url='+url+'&title='+title+'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=205&width=160&modal=false';
	return;
}
function emailThis(thelink){
	var url=location.href.replace("&", "-amp-");
	url=location.href.replace("?", "-que-");
	var title=document.title;
	thelink.href='/popups.php?action=emailthis&url='+url+'&title='+title+'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=140&width=550&modal=false';
	return;
}
function fullVideo (fn,w,h) {
	var width=w+6;
	var height=h+29;
	var thlink='/popups.php?action=video&amp;fn='+fn+'&amp;w='+w+'&amp;h='+h+'&amp;placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height='+height+'&amp;width='+width+'&amp;modal=false';
	tb_show('Video',thlink,null);
}
function videoPopup(f,w) {
	w= w!=0 ? w : 800;
	h=616;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	videoInfoWindow=window.open('/popups.php?action=qvideo&f='+f+'&w='+w,'video',settings);
	videoInfoWindow.focus();
}

function launchPlayer() {
	w=430;
	h=320;
	LeftPosition = 15;
	TopPosition =15;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	var path;
	path='/pbplayer.php';
	playerWindow=window.open(path,'playerWindow',settings);
	playerWindow.focus();
}


function shareThis(thelink){
	var url=location.href;
	//url=url.replace("&", "-amp-");
	//url=url.replace("?", "-que-");
	//url=url.replace("/", "-sla-");
	var title=document.title;
	switch(thelink.title){
		case 'Digg':
			shareLink='digg.com/submit?url='+url+'&title='+title;
			break;
		case 'Delicious':
			shareLink='del.icio.us/post?url='+url+'&title='+title;
			break;
		case 'Facebook':
			shareLink='www.facebook.com/sharer.php?u='+url+'&utm_source=facebook_1&t='+title;
			break;
		case 'ReddIt':
			shareLink='reddit.com/submit?url='+url+'&title='+title;
			break;
		case 'StumbleUpon':
			shareLink='www.stumbleupon.com/submit?url='+url+'&title='+title;
			break;
		case 'Twitter':
			shareLink='twitter.com/Point_Blank';
			break;
		case 'FaceBook':
			shareLink='www.facebook.com/pointblankcollege';
			break;
		case 'MySpace':
			shareLink='myspace.com/pointblanklondon';
			break;
		case 'YouTube':
			shareLink='youtube.com/pointblankonline';
			break;
		case 'SoundCloud':
			shareLink='soundcloud.com/point-blank';
			break;
	}
	//thelink.href='/link/'+escape(encodeURIComponent(shareLink));
	thelink.href='/link/'+escape(encodeURIComponent('http://'+shareLink));
	thelink.target='_blank';
	return;
}
function emailThis(thelink){
	var url=location.href.replace("&", "-amp-");
	url=location.href.replace("?", "-que-");
	var title=document.title;
	thelink.href='/popups.php?action=emailthis&url='+url+'&title='+title+'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=80&width=500&modal=true';
	return;
}
function submitSearch() {
	var phrase=document.getElementById('phrase').value;
	phrase=escape(encodeURIComponent(phrase));
	if (!phrase) {
		alert('Please enter search phrase.');
	} else {
		document.getElementById('searchForm').action='/search/'+phrase;
		document.getElementById('searchForm').submit();
	}
}

function validateSearch() {
	var phrase=document.getElementById('phrase').value;
	if (!phrase) {
		alert('Please enter search phrase.');
		return false;
	} else {
		document.getElementById('searchForm').action='/search/'+(phrase);
		return true;
	}
}


// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			CMS CUSTOMIZATION
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function saveInterfaceCookie (id,state) {
	var $c= readCookie('PointBlankCMSInterface');
	$cookieValue='';
	var $found = false;
	if ($c) {
		$cookieBits=$c.split(':::');
		for (var $i=0; $i<$cookieBits.length-1; $i++) {
			var bitBits=$cookieBits[$i].split('=');
			$key=bitBits[0];
			$val=bitBits[1];
			if (id==$key) {
				$cookieValue=$cookieValue+$key+'='+state+':::';
				$found=true;
			} else {
				$cookieValue= $cookieValue+$key+'='+$val+':::';
			}
		}
	}
	if (!$found) {
		$cookieValue=$cookieValue+id+'='+state+':::';
	}
	//eraseCookie('PointBlankCMSInterface');
	createCookie('PointBlankCMSInterface',$cookieValue,365);
}

function hideContentBoxesOnLoad () {
	var $c= readCookie('PointBlankCMSInterface');
	//alert($c);
	if ($c) {
		$cookieBits=$c.split(':::');
		var $found = false;
		for (var $i=0; $i<$cookieBits.length-1; $i++) {
			var bitBits=$cookieBits[$i].split('=');
			$key=bitBits[0];
			$val=bitBits[1];
			var id=document.getElementById($key);
			if (id && $val=='false') {
				contentShowHide($key);
			}
		}
	}
}

function contentShowHide(id){
	contentDiv=document.getElementById(id);
	linkDiv=document.getElementById(id+'SH');
	//alert(contentDiv.style.display);
	if (contentDiv.style.display == 'none'){
		contentDiv.style.display = '';
		linkDiv.innerHTML='hide';
		saveInterfaceCookie(id,'true');
	} else {
		contentDiv.style.display = 'none';
		linkDiv.innerHTML='show';
		saveInterfaceCookie(id,'false');
	}
}
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			COOKIES
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

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;
	return '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			CLEAR FORMS
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); ) 	{
			if (elm.getAttribute('type') == "text")	{
				elm.value = '';
			}
			if (elm.getAttribute('type') == "checkbox")	{
				elm.checked=false;
			}
			if (elm.getAttribute('type') == "radio")	{
				elm.checked=false;
			}
		}
		elements = form.getElementsByTagName('select');
		for( i=0, elm; elm=elements.item(i++); )	{
			elm.options.selectedIndex=0;
		}
	}

	// Actually looking through more elements here
	// but the result is the same.
	else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")	{
				elm.value ='';
			}
			if (elm.type == "select")		{
				elm.options.selectedIndex=0;
			}
			if (elm.type == "checkbox") 	{
				elm.checked=false;
			}
			if (elm.type == "radio") 	{
				elm.checked=false;
			}
		}
	}
	form.submit();
}


// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			CHECKING EMAIL
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function checkIdentifier(ID,identifier) {
	getpost = "POST";
	var http_request = false;
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	var message = document.getElementById('identifierMessage');
	
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4 && http_request.status == 200) {
			// got response
			message.innerHTML='';
			if (http_request.responseText=='found') {
				message.innerHTML='<span style="color:#FF0000">Error: identifier must be unique.</span>';
			}
		} else {
			message.innerHTML='<span style="color:#FFCC00">Checking identifier. Please wait...</span>';
		}
	};
	http_request.open(getpost, 'process.php?from=checkIdentifier&ID='+ID+'&identifier='+identifier, true);
	if(getpost == "POST") {
		http_request.send('');
	} else {
		http_request.send(null);
	}
	//http_request.open("POST","test_get_values.php",true);
	//http_request.send('topic=mp');
}


// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			CURSORS
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function cursor_hand() {
document.body.style.cursor = 'wait';
}

// Returns the cursor to the default pointer
function cursor_clear() {
document.body.style.cursor = 'default';
}

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			DREAMWEAVER
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			TINY EDITOR
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function initTinyMCE (elementID,settingID, height, resize) {
	if ((navigator.userAgent.indexOf("iPhone") == -1 && navigator.userAgent.indexOf("iPod") == -1 && navigator.userAgent.indexOf("iPad") == -1)) {
	var paramHeight = height!=null ? height : 100;
	var paramResize = resize!=null ? resize : true;
	tinyMCE.settings = {
		entity_encoding : "named",
		entities : "39,#39,160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute",
			remove_linebreaks : true,
			apply_source_formatting : false,
			mode : "textareas",
			theme : "advanced",
			skin : "o2k7",
			skin_variant : "silver",
			editor_selector : "mceEditor",
			width : "100%",
			height : paramHeight,
			content_css : "/include/mce_editor.css",
			extended_valid_elements : "a[href|target|name|class|title|style],span[class|style],div[class|style|id],li[class|style],p[class|style],style[type]",
			theme_advanced_styles : "Course overview=overview;Subchapter=header1;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight;Image Caption=imageCaption;Popup link=thickbox", // Theme specific setting CSS classes
			plugins : "table,save,preview,advimage,contextmenu,paste,media,tinybrowser,contentelements,spellchecker,heading,fullscreen,codemirror",
			spellchecker_languages : "+English=en",
			theme_advanced_buttons1 : "save,separator,undo,redo,separator,pastetext,pasteword,separator,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,h1,h2,h3,styleselect",
			theme_advanced_buttons2 : "tablecontrols,separator,sub,sup,separator,image,InsertContentElements,separator,link,unlink,separator,hr,separator,removeformat,cleanup,codemirror,spellchecker,fullscreen",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_path : true,
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			//external_image_list_url : imagelist,
			paste_use_dialog : false,
			paste_auto_cleanup_on_paste : true,
			paste_force_cleanup_wordpaste : true,
			paste_strip_class_attributes : "all",
			paste_create_linebreaks : false,
			paste_remove_spans : true,
			paste_remove_styles : true,
			//paste_insert_word_content_callback : "convertWord",
			paste_preprocess : function(pl, o) {
				// Content string containing the HTML from the clipboard
				//alert(o.content);
			},
			paste_postprocess : function(pl, o) {
				// Content DOM node containing the DOM structure of the clipboard
				//alert(o.node.innerHTML);
			},
			theme_advanced_resizing : paramResize,
			theme_advanced_resize_horizontal : false,
			paste_auto_cleanup_on_paste : true,
			force_p_newlines : true,
			force_br_newlines : false,
			auto_resize : false,
			relative_urls : false,
			file_browser_callback : "tinyBrowser",
			// file manage buttons
			setup : function(ed) {
			  ed.onSaveContent.add(function(ed, o) {
				   // Remove all paragraphs and replace with BR
					//o.content=o.content.replace(/<p>\[/ig, '[');
					//o.content=o.content.replace(/\]<\/p>/ig, ']');
				  });
				// Add a custom button
				ed.addButton('browseimages', {
					title : 'Image manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browseimages.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('image','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
				ed.addButton('browsemultimedia', {
					title : 'Media manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browsemultimedia.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('media','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
				ed.addButton('browse', {
					title : 'File manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browse.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('file','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
			}
		
	}
	
	switch (settingID) {
		case 1: /*simple editors right hand side, homepage small boxes*/
			tinyMCE.settings.content_css = "/include/mce_editor_simple.css";
			tinyMCE.settings.extended_valid_elements = "a[href|target|name|class|title],span[class],div[class|id],li[class],p[class|id]";
			tinyMCE.settings.theme_advanced_styles = "Header 13=header13;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Caption=imageCaption;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight; ThickBox=thickbox";
			tinyMCE.settings.plugins = "paste,spellchecker,tinybrowser";
			tinyMCE.settings.theme_advanced_buttons1 = "undo,redo,separator,bold,italic,underline";
			tinyMCE.settings.theme_advanced_buttons2 = ",link,unlink,separator,removeformat,cleanup,spellchecker";
			break;
		case 2: /*limited editors for forums and user inputs*/
			tinyMCE.settings.extended_valid_elements = "a[href|target|name|class|title],span[class],div[class],li[class],p[class]";
			tinyMCE.settings.theme_advanced_styles = "Header 13=header13;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Caption=imageCaption;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight; ThickBox=thickbox";
			tinyMCE.settings.plugins = "paste,spellchecker,soundcloud";
			tinyMCE.settings.theme_advanced_buttons1 = "undo,redo,separator,bold,italic,underline,separator,removeformat,cleanup,spellchecker,separator,soundcloud";
			tinyMCE.settings.theme_advanced_buttons2 = "";
			tinyMCE.settings.theme_advanced_path = false;
			break;	
		case 3: 	/*editor for home banner only*/
			tinyMCE.settings.skin_variant = "black";
			tinyMCE.settings.extended_valid_elements = "a[href|target|name|class|title],span[class|style],div[class|style],li[class|style],p[class|style]";
			tinyMCE.settings.theme_advanced_styles = "Subchapter=header1;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight;Image Caption=imageCaption";
			tinyMCE.settings.plugins = "table,save,preview,advimage,contextmenu,paste,media,tinybrowser,spellchecker,heading,codemirror";
			tinyMCE.settings.theme_advanced_buttons1 = "save,separator,undo,redo,separator,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,h1,styleselect,separator,outdent,indent";
			tinyMCE.settings.theme_advanced_buttons2 = "tablecontrols,separator,image,separator,link,unlink,separator,hr,separator,removeformat,cleanup,codemirror,spellchecker";
			break;
		case 4: /*simple editor for spotlight on*/
			tinyMCE.settings.content_css = "/include/mce_editor_simple.css";
			tinyMCE.settings.extended_valid_elements = "a[href|target|name|class|title|style],span[class|style|id],div[class|style|id],li[class|style],p[class|style|id]";
			tinyMCE.settings.theme_advanced_styles = "Header 13=header13;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Caption=imageCaption;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight; ThickBox=thickbox";
			tinyMCE.settings.plugins = "table,paste,spellchecker,tinybrowser,advimage,heading,codemirror";
			tinyMCE.settings.theme_advanced_buttons1 = "bold,italic,underline,justifyleft,justifycenter,justifyright,h1,h2,h3";
			tinyMCE.settings.theme_advanced_buttons2 = "link,unlink,separator,image,separator,removeformat,cleanup,codemirror,spellchecker";
			break;
		case 5: /*limited editors for developing elements*/
			tinyMCE.settings.extended_valid_elements = "a[href|target|name|class|title],span[class],div[class],li[class],p[class]";
			tinyMCE.settings.theme_advanced_styles = "Header 13=header13;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Caption=imageCaption;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageBorderLeft;Image on right with border=imageBorderRight; ThickBox=thickbox";
			tinyMCE.settings.plugins = "paste,spellchecker";
			tinyMCE.settings.theme_advanced_buttons1 = "undo,redo,separator,bold,italic,underline,separator,link,unlink,separator,removeformat,cleanup,spellchecker";
			tinyMCE.settings.theme_advanced_buttons2 = "";
			tinyMCE.settings.theme_advanced_path = false;
			break;
		case 6: /* 3 full editor with 3 rows of buttons */
			tinyMCE.settings.theme_advanced_buttons1 ="save,separator,undo,redo,separator,pastetext,pasteword,separator,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,h1,h2,h3,styleselect";
			tinyMCE.settings.theme_advanced_buttons2 = "tablecontrols,separator,sub,sup,separator,image,InsertContentElements,separator,link,unlink,separator,hr";
			tinyMCE.settings.theme_advanced_buttons3 = "removeformat,cleanup,codemirror,spellchecker,fullscreen";
			break;
	}
	
	tinyMCE.execCommand('mceAddControl', false, elementID);
	} else {
		var editor=document.getElementById(elementID);
		editor.className='textInput';
		editor.style.width='99%'
		editor.style.height=height+'px';
	}
}

function callMceEditor(type, dir) {
	if (type=='full') {
		//imagelist="/include/image_list.php?browse="+dir;
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			skin : "o2k7",
			skin_variant : "silver",
			editor_selector : "mceEditor",
			width : "100%",
			content_css : "/include/mce_editor.css",
			extended_valid_elements : "a[href|target|name|class|title]",
			theme_advanced_styles : "Header 13=header13;Orange Bold=header2;Table Body=tableBody;Table Header=tableHeader;Table Background=tableBack;Image Caption=imageCaption;Image Border=imageBorder;Image on left=imageLeft;Image on right=imageRight;Image on left with border=imageLeftBorder;Image on right with border=imageRightBorder; ThickBox=thickbox", // Theme specific setting CSS classes
			plugins : "table,save,preview,advimage,zoom,contextmenu,paste,media,tinybrowser,contentelements,spellchecker",
			spellchecker_languages : "+English=en",
			theme_advanced_buttons1 : "save,separator,undo,redo,separator,pastetext,pasteword,separator,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,styleselect,separator,outdent,indent,sub,sup",
			theme_advanced_buttons2 : "tablecontrols,separator,image,media,InsertContentElements,separator,browseimages,browsemultimedia,browse,separator,link,unlink,separator,hr,separator,removeformat,cleanup,code,spellchecker",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			//external_image_list_url : imagelist,
			paste_use_dialog : false,
			paste_auto_cleanup_on_paste : true,
			paste_force_cleanup_wordpaste : true,
			paste_strip_class_attributes : "all",
			paste_create_linebreaks : false,
			paste_remove_spans : true,
			paste_remove_styles : true,
			//paste_insert_word_content_callback : "convertWord",
			paste_preprocess : function(pl, o) {
				// Content string containing the HTML from the clipboard
				//alert(o.content);
			},
			paste_postprocess : function(pl, o) {
				// Content DOM node containing the DOM structure of the clipboard
				//alert(o.node.innerHTML);
			},
			theme_advanced_resizing : true,
			theme_advanced_resize_horizontal : false,
			paste_auto_cleanup_on_paste : true,
			force_br_newlines : false,
			auto_resize : false,
			relative_urls : false,
			file_browser_callback : "tinyBrowser",
			// file manage buttons
			setup : function(ed) {
				// Add a custom button
				ed.addButton('browseimages', {
					title : 'Image manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browseimages.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('image','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
				ed.addButton('browsemultimedia', {
					title : 'Media manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browsemultimedia.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('media','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
				ed.addButton('browse', {
					title : 'File manager',
					image : '/tinymce/jscripts/tiny_mce/themes/advanced/img/browse.gif',
					onclick : function() {
						// Add you own code to execute something on click
						tinyBrowserPopUp('file','');
						//ed.selection.setContent('<strong>Hello world!</strong>');
					}
				});
			}
		
		});
	}
}

function convertWord (type, content) {
    switch (type) {
        // Gets executed before the built in logic performs it's cleanups
        case "before":
            //content = content.toLowerCase(); // Some dummy logic
           // alert(content);
            break;
        // Gets executed after the built in logic performs it's cleanups
        case "after":
            //alert(content);
            content = content.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g,'');
			//alert(content);
            //content = content.toLowerCase(); // Some dummy logic
            //alert(content);
            break;
    }
    return content;
}

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			HIGHLIGHTING ROWS
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function highlight_rows_init() {
var rows = document.getElementsByTagName('div');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( rows[i].className.substr(rows[i].className.length,-7) == 'listRow' ) {
			// ... add event listeners ...
			// ... to highlight the row on mouseover ...
			if ( navigator.appName == 'Microsoft Internet Explorer' ) {
				// but only for IE, other browsers are handled by :hover in css
				rows[i].onmouseover = function() {
					this.className += 'IEhover';
				}
				rows[i].onmouseout = function() {
					this.className = this.className.replace( 'IEhover', '' );
				}
			}
        }
	}
}
//window.onload=highlight_rows_init;

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			TRAIL IMAGE
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 60;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimageid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimageid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(content){
	document.onmousemove=followmouse;
	//cursor_hand();

	newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #c7c7c7; font-size:12px">';
	newHTML = newHTML + content;
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
	gettrailobj().position="absolute";
	gettrailobj().zIndex="999";
	currentimageheight = $('trailInnerDiv').offsetHeight;	
	currentTrailWidth = gettrailobjnostyle().offsetWidth;
}

function hidetrail(){
	//cursor_clear();
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < currentTrailWidth){
			xcoord = e.pageX - xcoord - currentTrailWidth + 0; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < currentTrailWidth){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - currentTrailWidth + 0; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

// 2010-02-16 v2
// Will Critchlow, Distilled, http://www.distilled.co.uk

// 2010-02-09 v1
// 2010-02-16 v2 - added function distilledTruncate() and distilledFirstTouch()

// With thanks to http://www.quirksmode.org/js/cookies.html
function distilledCheckAnalyticsCookie() {
	var cookiename = "__utma";
	var cookiecheck = 0;
	var cookies = document.cookie.split(';');
	for (var i=0;i<cookies.length;i++){
		while (cookies[i].charAt(0)==' ') cookies[i] = cookies[i].substring(1,cookies[i].length);
		if (cookies[i].indexOf(cookiename+'=') == 0){
			cookiecheck = 1;
		} //if
	} //for
	return cookiecheck;
}//distilledCheckAnalyticsCookie

//truncate to 63 characters after URL encoding. Decode before returning - to avoid encoding twice
function distilledTruncate(input) {
	var byteLength = 63;
	return decodeURIComponent(encodeURIComponent(input).substr(0,byteLength));
}//distilledTruncate

function distilledFirstTouch(pageTracker){
	//make sure that any error with our code will not cause general GA tracking to fail
	try {
		if (distilledCheckAnalyticsCookie() === 0){
		
			//note that setCustomVar has a max of 64 bytes for combination of variable name and value hence cryptic variable names
			//all variables are truncated to 63 characters after URL encoding to ensure we get as much information as possible in GA
			
			//l = original landing page (no query string)
			//s = original landing page query string
			//r = original referrer
			//q = if keyword information is found, this contains that part of the referrer (based on Google's list of query delimiters: http://code.google.com/apis/analytics/docs/tracking/gaTrackingTraffic.html#searchEngine)
			
			pageTracker._setCustomVar(1, "l", distilledTruncate(window.location.pathname), 1);
			pageTracker._setCustomVar(2, "s", distilledTruncate(window.location.search), 1);
			
			//for the referrer, substring out the http:// from the beginning (the first 7 characters)
			pageTracker._setCustomVar(3, "r", distilledTruncate(document.referrer.substr(7,document.referrer.length)), 1);
			pageTracker._setCustomVar(4, "q", distilledTruncate(document.referrer.match(/(?:([#]|[?]|[&]))(?:(encquery|k|p|q|qs|qt|query|rdata|search_word|szukaj|terms|text|wd|words))=[^&]*/i)[0]), 1);
			
		} //if
	} catch (err) {} // try
}//distilledFirstTouch

function playQTMovie(id) {
	var movie=eval('document.qtmovie'+id);
	if (document.getElementById('movieHolder'+id).style.display=='block')
		movie.Play();
	document.getElementById('movieHolder'+id).style.display='block';
	document.getElementById('movieThumb'+id).style.display='none';
	document.getElementById('btnPlay'+id).style.display='none';
	document.getElementById('btnStop'+id).style.display='block';
}
function stopQTMovie(id) {
	var movie=eval('document.qtmovie'+id);
	if (document.getElementById('movieHolder'+id).style.display=='block')
		movie.Stop();
	document.getElementById('btnPlay'+id).style.display='block';
	
	document.getElementById('btnStop'+id).style.display='none';
}
function playQTFS(id, fn) {
	var movie=eval('document.qtmovie'+id);
	if (document.getElementById('movieHolder'+id).style.display=='block')
		movie.Stop();
	document.getElementById('btnPlay'+id).style.display='block';
	document.getElementById('btnStop'+id).style.display='none';
	document.getElementById('movieHolder'+id).style.display='none';
	document.getElementById('movieThumb'+id).style.display='block';
	tb_open_new('Movie','/popups.php?action=qtvideo&fn='+fn+'&placeValuesBeforeTB_=savedValues&TB_iframe=true&width=960&height=626&modal=false','');
}

