var DHTML = (document.getElementById || document.all || document.layers);
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
function toHide(action)
{
  var url = 'http://www.karrana.net/Forum/change_status.php?act=hide&name=';
  xmlhttp.open('GET', url + escape(action), true);
  xmlhttp.send(null);
}
function toShow(action)
{
  var url = 'http://www.karrana.net/Forum/change_status.php?act=show&name=';
  xmlhttp.open('GET', url + escape(action), true);
  xmlhttp.send(null);
}
function getObj(name)
{
  if (document.getElementById) {
  	return document.getElementById(name);
  }
  else if (document.all) {
	return document.all[name];
  }
  else if (document.layers) {
   	return document.layers[name];
  }
  else return null;
}
function change(name)
{
    if (!DHTML) return;
    d = getObj(name + '_block');
    c = getObj(name + '_collapse');
    if (c) {
        if (d.style.display == 'block')
            c.src = c.src.replace(/minus/, 'plus');
        else
            c.src = c.src.replace(/plus/, 'minus');
    }
    if (d.style.display == 'none')
    	toShow(name + '_block');
    else
    	toHide(name + '_block');
    d.style.display = d.style.display == 'none' ? 'block' : 'none';
}
function show(name)
{
    if (!DHTML) return;
    var url = 'http://www.karrana.net/Forum/change_status.php?act=show&name=';
  	xmlhttp.open('GET', url + escape(name + '_block'), true);
  	xmlhttp.onreadystatechange = function() {
		  if (xmlhttp.readyState==4) { location.href='http://www.karrana.net/Forum/'; }}
  	xmlhttp.send(null);
}

// COMMON SKIN_TOPIC JS

function delete_post(theURL)
{
	if (confirm('هل تود فعلاً حذف هذه المشاركة؟'))
	{
		window.location.href=theURL;
	}
	else
	{
		alert ('حسناً؛ لم يتخذ أي إجراء..');
	} 
}
function PopUp(url, name, width,height,center,resize,scroll,posleft,postop)
{
	if (posleft != 0) { x = posleft }
	if (postop  != 0) { y = postop  }
	if (!scroll) { scroll = 1 }
	if (!resize) { resize = 1 }
	if ((parseInt (navigator.appVersion) >= 4 ) && (center))
	{
		X = (screen.width  - width ) / 2;
		Y = (screen.height - height) / 2;
	}
	if (scroll != 0) { scroll = 1 }
	var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}

function ShowHide(id1, id2)
{
	if (id1 != '') expMenu(id1);
	if (id2 != '') expMenu(id2);
}

function ValidateForm()
{
	MessageLength  = document.REPLIER.Post.value.length;
	errors = '';
		
	if (MessageLength < 2)
	{
		errors = "يجب إدخال نص للإدراج!";
	}
	if (errors != '')
	{
		alert(errors);
		return false;
	}
	else
	{
		document.REPLIER.submit.disabled = true;
		return true;
	}
}
	
function expMenu(id)
{
	var itm = getObj(id);
		
	if (!itm) {
	// do nothing
	}
	else if (itm.style)
	{
		if (itm.style.display == 'none') { itm.style.display = ''; }
		else { itm.style.display = 'none'; }
	}
	else { itm.visibility = 'show'; }
}

function HighlightAll(theField)
{
	var tempval=eval(theField);
	var copytoclip=1
	tempval.select();
	if (document.all&&copytoclip==1)
	{
		therange=tempval.createTextRange();
		therange.execCommand("Copy");
		window.status="تم نسخ الشفرة بنجاح";
		setTimeout("window.status=''",2400);
	}
}
function emo_pop()
{
	window.open('index.php?act=legends&amp;CODE=emoticons','Legends','width=400,height=500,resizable=yes,scrollbars=yes');
}