var PHP_SELF = document.location.href.split('?')[0];
var DOMAIN = 'http://' + document.domain;

/*
	u - url
	p - popup name
*/
function popup(u,p,w,h,s,r){s=!s?'no':'yes';r=!r?'no':'yes';var x=Math.round((screen.availWidth-w)/2);var y=Math.round((screen.availHeight-h)/2);newwin = window.open(u,p,"left="+x+",top="+y+", scrollbars="+s+",resizable="+s+",width="+w+",height="+h+",menubar=no");return false;}

// show / hide elements
function show(id){if(document.getElementById(id)) document.getElementById(id).style.display=''}
function hide(id){if(document.getElementById(id)) document.getElementById(id).style.display='none'}

// check / uncheck all
//<input title="Select / deselect all" type="checkbox" id="checkall" name="checkall" onclick="checkall(this,'arr_cat_ids[]')" value="1">
function checkbox_checkall(box,obj){var f=box.form.name;var o=document.forms[f].elements[obj];var b=document.forms[f].elements[box.name];if(b.value==1){var c=true;b.value=0;}else{var c=false;b.value=1;}b.checked=c;if(typeof o!='undefined'){for (var i=0;i<o.length;i++){o[i].checked=c;}}}

//js links
function link_review_write(section,code){document.location = '/pages/review.php?section='+section+'&code='+code;}
function link_review_helpful(url,id){document.location = url+'?review_action=helpful&review_id='+id + '&rand='+Math.random()+'#review' + id;}
function link_review_not_helpful(url,id){document.location = url+'?review_action=not_helpful&review_id='+id + '&rand='+Math.random()+'#review' + id;}
function link_review_report(url,id){
	if(confirm('Do you want to report this review as abusive and / or off-topic?')){document.location = url+'?review_action=report&review_id='+id + '#review' + id;}
	return false;
}

function home(){document.location = DOMAIN;}

// allowed symbols
function symbolsleft(obj, objt, max, skip_alert)
{
	var e=document.getElementById(objt);
	if(!e||e=='undefined'||e==null)return false;
	if(obj.value.length > max)
	{
		obj.value=obj.value.substring(0,max);
		e.innerHTML=0;
		if(!skip_alert) alert('Maximum allowed symbols: ' + max);
	}
	else{e.innerHTML=max-obj.value.length;}
}

function browserBookmark(t){t=!t?document.title:t;var u=document.location.href;if(window.sidebar){window.sidebar.addPanel(t,u,"");}else if(document.all&&window.external){window.external.AddFavorite(u,t);}else if(window.opera &&window.print){alert('Opera users - press Ctrl + T to bookmark');}return true;}

