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];}}
}
function popUp(URL,w,h) {
day = new Date();
id = day.getTime();
if (w==""){w="300"}
if (h==""){h="300"}
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+"');");
}
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_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_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 checkdata() {

		 
     if (document.story_form.subject.value.length==0)
			{

		  alert("Please Insert a Title");

		  document.story_form.subject.focus();

			return false;
		}
		 
		  if (document.story_form.catid.value == 0 )
			{

		  alert("Please Select a Section");

		  document.story_form.catid.focus();

			return false;
			 }
			
			 if (document.story_form.terrtory1.value == ""  && document.story_form.ihome[0].checked)
			{

		  alert("Please Select an  Area at HomePage");

		  document.story_form.terrtory1.focus();

			return false;
			 }
			 if (document.story_form.terrtory2.value == "" )
			{

		  alert("Please Select an  Area at Category Page");

		  document.story_form.terrtory2.focus();

			return false;
			 }

	 return true;

     }
       



function showHide(obj, image)
{
    if(obj.style.display == 'none')
    {
        obj.style.display = '';
        if(image != null)
          image.src = imageUp.src;
    }
    else
    {
        obj.style.display = 'none';
        if(image != null)
          image.src = imageDown.src;
    }
}
function show(secid) {
var id='';
document.getElementById('agencylayer').style.visibility = "hidden";
document.getElementById('picturelayer').style.visibility = "hidden";
if((secid==5 || secid==7 || secid==8))
{
if(document.getElementById('picturelayer').style.visibility == "hidden")
	document.getElementById('picturelayer').style.visibility = "visible";
}if((secid==9 || secid==10  || secid==11))
{
if(document.getElementById('agencylayer').style.visibility == "hidden")
	document.getElementById('agencylayer').style.visibility = "visible";
}
}
function CheckAll(fmobj,cond,msg)
{
if(msg)
{
var s=confirm(msg);
}
if((s && msg) || !msg)
{
	for (var i=0;i<fmobj.elements.length;i++)
	{
		var e = fmobj.elements[i];
		
		if(e.type=='checkbox')
		{
		var str=e.name;
		
		str=str.substr(0,4);
		
		}
		if ((e.type=='checkbox') && (!e.disabled) && str==cond)
		{
		e.checked = true;
			 
		}
	}
	}
}

function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
w = document.getElementById('iframename').contentDocument.body.scrollWidths;
document.getElementById('iframename').style.height = h;
document.getElementById('iframename').style.width = w;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
w = document.frames('iframename').document.body.scrollWidth;
document.all.iframename.style.height = h;
document.all.iframename.style.width = w;
}

}
function disableIt(obj,stat)
{
	obj.disabled = stat;
	 (obj.disabled) ? 'disabled' : 'enabled';
}
function checkValidations(txtContent)
{
	if(Trim(window.document.all.item(txtContent).value) == '' )
	{
		alert("الرجاء ادخال النص المراد البحث عنه\n please insert the text that you want to seach \nVeuillez insére le text que vous voulez chercher");
		return false;
	}
	else
	{
	if(txtContent=="search_xte_plugin")
	window.document.gosearch.submit();
	if(txtContent=="searchsrv")
	window.document.picsearch.submit();
	if(txtContent=="presidentsearch")
	window.document.gosearchpresident.submit();
		return true;
	}
}
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

var submitcount=0;
function checkvote(){
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else 
      {

      return false;
      }
}

