//==============================================================================
//                         Set Screen Resolution Cookie
//==============================================================================
function setScreenResolutionCookie() {

  // returns false if cookies are disabled on PC

  if ( get_cookie("sceenResolution") != "" ) {
     return true;
  }

   if ((screen.width>=1024) && (screen.height>=768)) {
      sceenRes = "high";
   } else {
      sceenRes = "low";
   }

   //set document cookies
   document.cookie="sceenResolution="+sceenRes;

   // check for the posibility that coockies are disabled on the user's PC
   if ( get_cookie("sceenResolution") == "" ) {
      // here we have two options, either inforce cookies or consider resolution (in the code) as being low
      // alert("Important: this site uses Session Cookies ... please enable cookies in order for this site to work correctly");
      return false;
   } else {
      document.location.reload();
   }
}
//==============================================================================
//                      Stuff Controlled With Cookie Use
//==============================================================================

function enableShareet(value) {
  var currentValue = get_cookie("displayShareetContents");
  if ( (currentValue == value) || (currentValue == "" && value == 'TRUE') ) {
     return;
  }

  document.cookie="displayShareetContents=" + value;
  if ( cookiesEnabledCheck("displayShareetContents") ) {
     document.location.reload();
  }
  return;
}
//------------------------------------------------------------------------------

function setStyle(style) {
  var currentStyle = get_cookie("style");
  if ( (currentStyle == style) || (currentStyle == "" && style == "rokhamiFrame") ) {
     return;
  }

  document.cookie="style="+style;
  if ( cookiesEnabledCheck("style") ) {
     document.location.reload();
     warningMessage();
  }
}
//------------------------------------------------------------------------------

function showLeftSide(value) {  // value: auto, show, hide
alert(value);
  var currentValue = get_cookie("showLeftSide");
  if ( (currentValue == value) || (currentValue == "" && value == "auto") ) {
     return;
  }

  document.cookie="showLeftSide="+value;
  if ( cookiesEnabledCheck("showLeftSide") ) {
     // var sURL = unescape(window.location.pathname);
     // window.location.href = sURL;
     document.location.reload();
     warningMessage();
  }
}

function showLeftSide_2() {

  // remove: var leftSideShown = get_cookie("leftSideShown"); alert(leftSideShown);
  var leftSideShown = get_cookie("showLeftSide");
  if ( leftSideShown == "hide" ) {
     document.cookie="showLeftSide=show";
  } else {
     document.cookie="showLeftSide=hide";
  }

  if ( cookiesEnabledCheck("showLeftSide") ) {
     // var sURL = unescape(window.location.pathname);
     // window.location.href = sURL;
     document.location.reload();
     warningMessage();
  }
}

//------------------------------------------------------------------------------

function cookiesEnabledCheck(testCookie) {
  var cookieValue = get_cookie(testCookie);
  if ( cookieValue == "" ) {
     alert('معذرة، الكوكيز غير مفعلة على هذا الكمبيوتر ومن ثم هذه الخاصية لن تعمل');
     return false;
  }
  return true;
}

//------------------------------------------------------------------------------

function warningMessage() {
  var wasWarningMessageShown = get_cookie("wasWarningMessageShown");
  if ( wasWarningMessageShown == 'TRUE' ) return;
  document.cookie="wasWarningMessageShown ="+'TRUE';
  alert('الصفحات التي سبق تصفحها قد لا تعكس التغيير المطلوب. في مثل هذه الحالة، كل ما عليك عمله هو اختيار الزر الأيمن للماوس على تلك الصفحة ثم ريفريش. لن تظهر هذه الرسالة مرة اخرى أثناء جلسة التصفح هذه');
  return;
}

//==============================================================================
//  The followind code is left to show how to handle user input in JavaScript
//==============================================================================
/*
function setUserFrameBackground() {
   >===> Note: This code is left here as an example of how user's input can be used
   var bg_color = "#" + prompt("أدخل الكود السداسي للون الخلفية من إختيارك", "123456");
   if( bg_color == "#null" ) return;
   .....
}
*/
//==============================================================================<script>

var staticlogo=new Image(300,100)
var imgNum=3
var ranNum=Math.floor(Math.random()*imgNum)
var imgName=new Array(imgNum)
imgName[0]="../../www.khayma.com/logs/zuwar.jpg"
imgName[1]="../../www.khayma.com/logs/i3lan.gif"
imgName[2]="../../www.khayma.com/logs/taskeen.jpg"
staticlogo.src=imgName[ranNum]
var logolink="../../www.khayma.com/default.htm"
var alttext="الخيمة العربية"
var fadeintoview=1
var visibleduration=0

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",400)
}

var fadeset=''
if (fadeintoview)
fadeset="filter:alpha(opacity=0)"

if (document.all)
document.write('<span id="logo" style="'+fadeset+';position:absolute;top:100;width:'+staticlogo.width+';height:'+staticlogo.height+'"></span>')

function bringintoview(){
if (logo.filters.alpha.opacity<=95)
logo.filters.alpha.opacity+=5
else{
clearInterval(viewit)
if (visibleduration!=0)
setTimeout("logo.style.visibility='hidden'",visibleduration*1000)
}
}

function createlogo(){
staticimage=new Layer(100)
staticimage.left=-300
staticimage.top=120
staticimage.document.write('<a target=new href="'+logolink+'"><img src="'+staticlogo.src+'" border=0 alt="'+alttext+'"></a>')
staticimage.document.close()
staticimage.visibility="show"
regenerate2()
staticitns()
}

if (document.layers)
window.onload=createlogo;

if (document.all){
w=document.body.clientWidth-logo.style.pixelWidth-5
h=document.body.clientHeight-logo.style.pixelHeight-5
logo.style.left=5
logo.style.top=h
}

function logoit(){
var w2=document.body.scrollLeft+5
var h2=document.body.scrollTop+h
logo.style.left=w2
logo.style.top=h2
}
function logoit2(){
staticimage.left=pageXOffset+window.innerWidth-staticimage.document.width-15
staticimage.top=pageYOffset+window.innerHeight-staticimage.document.height
}

function insertimage(){
logo.innerHTML='<a target=new href="'+logolink+'"><img src="'+staticlogo.src+'" border=0 alt="'+alttext+'"></a>'
if (fadeintoview)
viewit=setInterval("bringintoview()",100)
else{
if (visibleduration!=0)
setTimeout("logo.style.visibility='hidden'",visibleduration*1000)
}
}

if (document.all){
window.onscroll=logoit
window.onresize=new Function("window.location.reload()")
window.onload=insertimage
}

function staticitns(){
setInterval("logoit2()",90)
if (visibleduration!=0)
setTimeout("staticimage.visibility='hide'",visibleduration*1000)
}

</script>
