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

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

function launchMixer(par) {
	var path;
	if (par) {
		path='/mixer/mixer.php' + par;
	} else {
		path='/mixer/mixer.php';
	}
	var width = 970;
    var height = 497;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    mixerWindow = window.open(path, "subWind", windowFeatures);
	mixerWindow.focus();
}

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('http://www.pointblanklondon.com/contact.php','contact',settings);
	contactInfoWindow.focus();
}
function radioInfo() {
	w=320;
	h=160;
	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='http://www.pointblanklondon.com/radiostation.php';
	uploadImageWindow=window.open(path,'radiostation',settings);
	uploadImageWindow.focus();
}

function shareThis(thelink){
	var url=location.href.replace("&", "-amp-");
	url=location.href.replace("?", "-que-");
	var title=document.title;
	thelink.href='http://www.pointblanklondon.com/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='http://www.pointblanklondon.com/popups.php?action=emailthis&url='+url+'&title='+title+'&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=140&width=550&modal=false';
	return;
}

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];}}
}

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			CUSTOMIZATION
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function saveInterfaceCookie (id,state) {
	var $c= readCookie('theHypeCustomize');
	$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');
	//alert ($cookieValue);
	createCookie('theHypeCustomize',$cookieValue,365);
}

function hideContentBoxesOnLoad () {
	var $c= readCookie('theHypeCustomize');
	//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');
	}
}

function fontSize(size) {
	saveInterfaceCookie('fontsize',size);
	window.location.reload();
}

function textOnly() {
	saveInterfaceCookie('textonly','1');
	window.location.reload();
}

function textAndImages() {
	saveInterfaceCookie('textonly','0');
	window.location.reload();
}

// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//																			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);
}



function callMceEditor() {
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			editor_selector : "mceEditor",
			width : "100%",
			height : "250",
			content_css : "/mce_editor.css",
			extended_valid_elements : "a[href|target|name]",
			theme_advanced_styles : "Header 1=header1;Header 2=header2", // Theme specific setting CSS classes
			plugins : "table,save,paste",
			theme_advanced_buttons1 : "save,separator,undo,redo,separator,pastetext,pasteword,separator,bold,italic,separator,styleselect,separator,sub,sup,separator,removeformat,cleanup",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			paste_use_dialog : true,
			theme_advanced_resizing : false,
			theme_advanced_resize_horizontal : false,
			paste_auto_cleanup_on_paste : true,
			theme_advanced_path : false,
			force_br_newlines : false
		});	
}