  function goToHome(locale){
try {
var str=window.location.href;
  var ii = str.indexOf("?");
  var iy = str.indexOf(";");
if(ii!=-1)
	str=str.substr(0,str.indexOf("?"));
if(iy!=-1)
    str=str.substr(0,str.indexOf(";"));
if(str.lastIndexOf("/")==str.length-1)
	str=str.substr(0,str.length-1);

if(str.indexOf("/home")==str.length-"/home".length )
{
    if (locale=="ar")
        document.getElementById("linkHome").innerHTML="<a href='http://www.government.ae/gov/ar/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
    else
        document.getElementById("linkHome").innerHTML="<a href='http://www.government.ae/gov/en/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
}
else if(str.indexOf("/guest")==str.length-"/guest".length )
{
    if (locale=="ar")
        document.getElementById("linkHome").innerHTML="<a href='http://www.government.ae/gov/ar/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
    else
        document.getElementById("linkHome").innerHTML="<a href='http://www.government.ae/gov/en/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
}
else
{
	if (locale=="ar")
    document.getElementById("linkHome").innerHTML="<a href='/web/guest/home' style='float: right; width: 200px; height:100px;margin-right:50px;'></a><a href='http://www.government.ae/gov/ar/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
    else
        document.getElementById("linkHome").innerHTML="<a href='/web/guest/home' style='float: right; width: 200px; height:100px;margin-right:50px;'></a><a href='http://www.government.ae/gov/en/index.jsp' style='float: left; width: 100px; height:100px;margin-left:50px; '></a>"
}
}
catch(ex)
{

}
}
function addMenuStyleToHeader(obj){
$('ul.mt-nav').children("li").removeClass("mt-select");

jQuery(obj).parents("ul").parents("li").addClass("mt-select");

}

function linkShowMenu(obj){
     $('ul.mt-nav').children("li").removeClass("mt-select");
     jQuery(obj).parents("li").addClass("mt-select");
}

function addMenuStyle(obj){
    $('ul.mt-nav').children("li").removeClass("mt-select");
    jQuery(obj).addClass("mt-select");
}
function removeMenuStyle(){
     $('ul.mt-nav').children("li").removeClass("mt-select");
}



function overMenuStyle(rightspan, centerspan , leftspan ,order )
{
    
    var rightstyle;
    var leftstyle;
    var centerstyle;
    if(order%3==1)
       {
           
           rightstyle="item1_right";
           centerstyle="item1_center";
           leftstyle= "item1_left";
       }
      if(order%3==2)
       {
           
           rightstyle="item2_right";
           centerstyle="item2_center";
           leftstyle= "item2_left";
       }
       if(order%3==0)
       {
          
           rightstyle="item3_right";
           centerstyle="item3_center";
           leftstyle= "item3_left";
       }
       document.getElementById(rightspan).className=rightstyle;
       document.getElementById(centerspan).className=centerstyle;
       document.getElementById(leftspan).className=leftstyle;
       
}

function outMenuStyle(rightspan, centerspan , leftspan)
{
     
    document.getElementById(rightspan).className="normal_right";
    document.getElementById(centerspan).className="normal_center";
    document.getElementById(leftspan).className="normal_left";
}
function changestyle(elmname){
	document.getElementById(elmname).style.borderColor="#ABABAB";
	document.getElementById(elmname).style.backgroundColor="#F9FDFF";

}
function changestyle2(elmname){
	document.getElementById(elmname).style.borderColor="#e8e8e8";
	document.getElementById(elmname).style.backgroundColor="#fdfdfd";

}


// start to handle search
function portalSearch(){

 document.location.href="/web/guest/search?p_p_id=3&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&_3_struts_action=/search/search&giaSearch="+encode(document.getElementById('search').value)
 return false;
}

function encode(string) {
return escape(this._utf8_encode(string));
}

// public method for url decoding
function decode(string) {
return this._utf8_decode(unescape(string));
}

// private method for UTF-8 encoding
function  _utf8_encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";

for (var n = 0; n < string.length; n++) {

var c = string.charCodeAt(n);

if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}

}

return utftext;
}

// private method for UTF-8 decoding
function  _utf8_decode(utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;

while ( i < utftext.length ) {

c = utftext.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}

// end of search handling

function gup( name )
{

  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );

  if( results == null )
    return "";
  else
      {


   if (results[1]=='menu2')
       {

        document.getElementById(results[1]).className="overState2";
        document.getElementById("menu1").className="overState1";

       }

     if (results[1]=='menu3')
       {

        document.getElementById(results[1]).className="overState3";
        document.getElementById("menu1").className="overState1";

       }
      if (results[1]=='menu4')
       {

        document.getElementById(results[1]).className="overState4";
        document.getElementById("menu1").className="overState1";

       }
       if (results[1]=='menu5')
       {

        document.getElementById(results[1]).className="overState2";
        document.getElementById("menu1").className="overState1";

       }
       if (results[1]=='menu6')
       {

        document.getElementById(results[1]).className="overState8";
        document.getElementById("menu1").className="overState1";

       }
       if (results[1]=='menu7')
       {

        document.getElementById(results[1]).className="overState7";
        document.getElementById("menu1").className="overState1";

       }
        if (results[1]=='menu8')
       {

        document.getElementById(results[1]).className="overState5";
        document.getElementById("menu1").className="overState1";

       }
        if (results[1]=='menu9')
       {

        document.getElementById(results[1]).className="overState6";
        document.getElementById("menu1").className="overState1";

       }
   }
}








/*--- login portlet ---*/
$(document).ready(function () {
	var $div = $('#login');
	var height = $div.height();
	$div.hide().css({ height : 0 });

	$('#logs').click(function () {
		if ($div.is(':visible')) {
			$div.animate({ height: 0 }, { duration: 300, complete: function () {
				$div.hide();
			} });
		} else {
			$div.show().animate({ height : height }, { duration: 300 });
		}

		return false;
	});
	$('#closeZoom').click(function () {
		if ($div.is(':visible')) {
			$div.animate({ height: 0 }, { duration: 300, complete: function () {
				$div.hide();
			} });
		} else {
			$div.show().animate({ height : height }, { duration: 300 });
		}

		return false;
	});


});

  // Reset Font Size
$(document).ready(function () {
    var originalFontSize = $('.mainBg').css('font-size');
    $(".resetFont").click(function(){
		$('.mainBg').css('font-size',12);
		$(this).addClass("selected1");
		$('.increaseFont2').removeClass("selected3");
		$('.increaseFont').removeClass("selected2");
    });
  // Increase Font Size
    $(".increaseFont").click(function(){
		var currentFontSize = $('.mainBg').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize);
		var newFontSize = 14;
		$('.mainBg').css('font-size', newFontSize);
		$(this).addClass("selected2");
		$('.resetFont').removeClass("selected1");
		$('.increaseFont2').removeClass("selected3");
		return false;
    });
  // Decrease Font Size
    $(".increaseFont2").click(function(){
		var currentFontSize = $('.mainBg').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize);
		var newFontSize = 16;
		$('.mainBg').css('font-size', newFontSize);
		$(this).addClass("selected3");
		$('.resetFont').removeClass("selected1");
		$('.increaseFont').removeClass("selected2");
		return false;
    });

    $('.field-clear').show();
	$('.field-field').hide();
	$('.field-clear').focus(function() {
		$(this).hide();
		$(this).next('.field-field').show();
		$(this).next('.field-field').focus();
	});
	$('.field-field').blur(function() {
		if($(this).val() == '') {
			$(this).hide();
			$(this).prev('.field-clear').show();
		}
	});
});


//-------------------------------------------------------------------------------
//                           Tool Tip
//-------------------------------------------------------------------------------
$(document).ready(function(){
$(".YassoTip").simpletooltip();
});
	
