/** * 
jQuery Cookie plugin * * 
Copyright (c) 2010 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: *
http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */
jQuery.cookie = function (key, value, options) {    // key and at least value given, set cookie...    
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '',        // use expires attribute, max-age is not supported by IE            
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''].join(''));
    }
    // key and possibly options given, get cookie...    
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};



function toggleTextOut(e, txtval) {
    if (e.value == "") e.value = txtval;

}
function toggleTextIn(e, txtval) {
    if (e.value == txtval) e.value = "";
    else e.select();
}

function doIt() {
    $("input.txt-search").css("display", "block");
    return false;
}

$(document).ready(function () {

    $(".swap").hover(
		function () {
		    if ($(this).attr("src").indexOf("-on.") == -1) {
		        var newSrc = $(this).attr("src");
		        newSrc = (newSrc.replace(/.jpg|.gif|.png/, '-on' + newSrc.substr(newSrc.length - 4)));
		        $(this).attr("src", newSrc);
		    } 
		},
		function () {
		    if ($(this).attr("src").indexOf("-on.") > 0) {
		        var oldSrc = $(this).attr("src").replace('-on.', '.');
		        $(this).attr("src", oldSrc);
		    };
		});

    $('a.sitemap-toggle').click(function () {
        $('.sitemap ul:first').toggle();
        $(this).toggleClass('sitemap-closed');
        if ($(this).parents('.sitemap').find('ul:first').is(':visible')) {
            $.cookie('sitemapstate', 'visible');
            $windowHeight = $(this).offset().top;
            $("html:not(:animated),body:not(:animated)").animate({ scrollTop: $windowHeight }, 500);
        } else {
            $.cookie('sitemapstate', 'hidden');
        }
        return false;
    });

    //Footer sitemap 
    if ($.cookie('sitemapstate') == 'visible') {
        $('.sitemap ul:first').show();
    } else {
       
        $('.sitemap ul:first').hide();
        $('a.sitemap-toggle').addClass('sitemap-closed');
    }


});





function OpenEmailConfirmation() {

    var html = '<HTML><HEAD><title>Thank You</title></head>';

    html += '<body bgcolor="#FFFFFF" style="margin:0;">';
    html += '<table width="450" border="0" cellpadding="0" cellspacing="0">';
    html += '<tr><td><img src="/_layouts/rostamani/images/img_email_01.gif" width="450" height="161" alt=""></td>';
    html += '</tr><tr><td><img src="/_layouts/rostamani/images/img_email_02.gif" width="450" height="50" alt=""></td></tr>';
    html += '<tr><td style="padding:0 20px;"><p style="color:#333;font-size:13px;font-family:Arial, Helvetica, sans-serif;">';
    html += 'Your queries/remarks will be personally addressed by one of our representatives. We appreicate all your comments and feedback.<br/><br/>';
    html += 'Regards<br/><span style="font-weight:bold;">Al Rostamani Group</span></p><br/></td></tr>'
    html += '<tr><td bgcolor="#666666" style="padding:15px 20px 30px 20px;">';
    html += '<p style="font-size:11px;color:#aaa;font-family:Arial, Helvetica, sans-serif;">&copy; Copyright International Energy Resources 2010. All rights reserved</p><br/>';
    html += '</td></tr></table></body></html>';
    var printWin = window.open("", "printSpecial", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=450,width=450");

    printWin.document.open();

    printWin.document.write(html);

}

function OpenCareerConfirmation() {

    var html = '<HTML><HEAD><title>Thank You</title></head>';

    html += '<body bgcolor="#FFFFFF" style="margin:0;">';
    html += '<table width="450" border="0" cellpadding="0" cellspacing="0">';
    html += '<tr><td><img src="/_layouts/rostamani/images/img_email_01.gif" width="450" height="161" alt=""></td>';
    html += '</tr><tr><td><img src="/_layouts/rostamani/images/img_email_02.gif" width="450" height="50" alt=""></td></tr>';
    html += '<tr><td style="padding:0 20px;"><p style="color:#333;font-size:13px;font-family:Arial, Helvetica, sans-serif;">';
    html += ' We appreicate your interest in us.We will get back to you based on your qualification and opening.<br/><br/>';
    html += 'Regards<br/><span style="font-weight:bold;">Al Rostamani Group</span></p><br/></td></tr>'
    html += '<tr><td bgcolor="#666666" style="padding:15px 20px 30px 20px;">';
    html += '<p style="font-size:11px;color:#aaa;font-family:Arial, Helvetica, sans-serif;">&copy; Copyright 2011 Al Rostamani Group. All rights reserved.</p><br/>';
    html += '</td></tr></table></body></html>';
    var printWin = window.open("", "printSpecial", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=450,width=450");

    printWin.document.open();

    printWin.document.write(html);

}
function printSpecial(tagname) {

    var html = '<HTML><HEAD>';



    if (document.getElementsByTagName != null)
     {

//        var headTags = document.getElementsByTagName("head");

//        if (headTags.length > 0)

//            html += headTags[0].innerHTML;

    }

    

    html += '</HEAD><BODY style="background-image:none;">';


    var printReadyElem = document.getElementById(tagname);

    html += '<H1><IMG title="Al Rostamani Group" alt="Al Rostamani Group" src="/_layouts/rostamani/images/logo-print.gif"></H1>';

    if (printReadyElem != null) {

        html += printReadyElem.innerHTML;

    }

    else {

        alert("Could not find the " + tagname + " div");

        return;

    }

    html += '</BODY></HTML>';



    var printWin = window.open("", "printSpecial");

    printWin.document.open();

    printWin.document.write(html);

    printWin.document.close();



    printWin.print();



}


function SendEmailToFriend() {

   
    var URL = window.location.href;
   
   
    window.location = "SendMailToFriend.aspx?URl=" + URL;
}

function ThanksAndSendBack() {
    alert("Thank you. Your link has been send to your friend.");
    var URL = window.location.search
    URL = URL.substring(URL.indexOf('URL=') + 6);
    window.location = URL;
}

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}
function ChangeLanguage()
{
	var URL = window.location.href;
	URL =URL.replace("/En","/Ar");
URL =URL.replace("/en","/ar");
URL =URL.replace("/EN","/AR");
URL =URL.replace("/eN","/aR");
	window.location = URL;
}

/*
CSS Browser Selector v0.3.2
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u) { var ua = u.toLowerCase(), is = function (t) { return ua.indexOf(t) > -1; }, g = 'gecko', w = 'webkit', s = 'safari', h = document.getElementsByTagName('html')[0], b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? g + ' ff2' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : /opera(\s|\/)(\d+)/.test(ua) ? 'opera opera' + RegExp.$2 : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js']; c = b.join(' '); h.className += ' ' + c; return c; }; css_browser_selector(navigator.userAgent);


