﻿//highlight right menu link
function highlightcurrentLink()
{
var breadCrumbLink=null;
if($('.NewBreadCrumb a').length>=4)
{
breadCrumbLink=$('.NewBreadCrumb a:eq(2)').attr('href').toLowerCase();
}
$('.right-list .list-border').each(function () {
   if( $(this).find('a').attr('href').toLowerCase()==location.pathname.toLowerCase())
   {
           $(this).addClass('current-link');
           } 
           else if(breadCrumbLink!=null && $(this).find('a').attr('href').toLowerCase()==breadCrumbLink)
           {
           $(this).addClass('current-link');
           }       
    });
}
highlightcurrentLink();
//bannar control
var pluzit_h = '06cf8ff6e544a088926fa212f725fbe6';
var pluzit_title = document.title;
var pluzit_bookmark_location = document.location;
var pluzit_logo = '1.jpg';
var pluzit_logo_background = 'EFEFFF';
var pluzit_logo_color = '00B3DB';
var pluzit_options = ['Favorites', 'Blogger', 'Facebook', 'MySpace', 'Twitter', 'Reddit', 'Google', 'Ask', 'Y! Mail', 'Hotmail'];
var CurrItem = 1,interval = setInterval("Scroll()", 5000);
//defined in control (itemsCount,fimageID,imgURlhf)
var cookieStartUpStatmentHidden = readCookie("StartUpStatmentHidden");
if(cookieStartUpStatmentHidden !=null && cookieStartUpStatmentHidden !='undefined')
{	$(".beta_container").hide(); 
	$(".experment").show();;
}
function MouseOver(x) {	
try {
xid = x.id.toString().substring(1, x.id.toString().length);
clearInterval(interval);
document.getElementById("d" + CurrItem.toString()).style.visibility = "hidden";
document.getElementById("b" + CurrItem.toString()).className = "Content-list-tab";
CurrItem = parseInt(xid.toString());var divId = "d" + xid;document.getElementById(divId).style.visibility = "visible";
document.getElementById("b" + CurrItem.toString()).className = "Scroll-rollover";
var imageUrl = document.getElementById("hf" + CurrItem.toString()).value.toString();
var imageAlt = document.getElementById("hfAlt" + CurrItem.toString()).value.toString();	
if (imageUrl != "" || imageUrl == null)document.getElementById(fimageID).src = imageUrl;
else document.getElementById(fimageID).src = document.getElementById(imgURlhf).value.toString();
document.getElementById(fimageID).title = imageAlt;
document.getElementById('fixedimage').href =  $("#d" + CurrItem.toString()+ " .Content-list-Title a").attr("href");
  }   catch (ex) { }	}
function MouseOut(x) {
try {interval = setInterval("Scroll()", 5000);}catch (ex) { }	}
function Scroll() {
try {
document.getElementById("d" + CurrItem.toString()).style.visibility = "hidden";
document.getElementById("b" + CurrItem.toString()).className = "Content-list-tab";
CurrItem++;
if (CurrItem == itemsCount) CurrItem = 1;
document.getElementById("d" + CurrItem.toString()).style.visibility = "visible";
document.getElementById("b" + CurrItem.toString()).className = "Scroll-rollover";
var imageUrl = document.getElementById("hf" + CurrItem.toString()).value.toString();
var imageAlt = document.getElementById("hfAlt" + CurrItem.toString()).value.toString();
if (imageUrl != "" || imageUrl == null)       
document.getElementById(fimageID).src = imageUrl;
else document.getElementById(fimageID).src = document.getElementById(imgURlhf).value.toString();
document.getElementById(fimageID).title = imageAlt;
document.getElementById('fixedimage').href =   $("#d" + CurrItem.toString()+ " .Content-list-Title a").attr("href");
} catch (ex) { }
}	
//End bannar control
function OnSelectionChange(value) 
{
    var today = new Date();
    var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
    var url = window.location.href;
    document.cookie = "lcid=" + value + ";path=/;expires=" + oneYear.toGMTString();
    if (url.indexOf('#') != -1)
        window.location = url.split('#')[0];
    else
        window.location = url;
    window.location = window.location.href;
} 
// Timer Control
if (window.addEventListener) {
window.addEventListener("load", startTimer, false);
}else if (window.attachEvent) {
window.attachEvent("onload", startTimer);
}else if (document.getElementById)
window.onload = startTimer;
var timerID = null;
var timerRunning = false;
var hours;
var minutes;
var seconds;
function stopTimer() {
        //stop the clock
        if (timerRunning) {
            clearTimeout(timerID);
            timerRunning = false;
        }
    } 
        function startTimer(hours,minutes,seconds,am,pm) {
        stopTimer();
        runClock();
    }

    function runClock() {
        document.getElementById('timeLabel').innerHTML = timeNow().replace(' am', am).replace(' pm', pm);
        //Notice how setTimeout() calls its own calling function, runClock().
        timerID = setTimeout("runClock()", 1000);
        timerRunning = true;
    }
    function timeNow() {
        //Grabs the current time and formats it into hh:mm:ss am/pm format.

        if (seconds == 59) {
            seconds = 00;
            if (minutes == 59) {
                minutes = 00;
                hours += 1;
            }
            else if (minutes <= 58)
                minutes += 1;
        }
        else if (seconds <= 58)
            seconds = seconds + 1;

        timeStr = "" + ((hours > 12) ? hours - 12 : hours);
        timeStr += ((minutes < 10) ? ":0" : ":") + minutes;
        timeStr += ((seconds < 10) ? ":0" : ":") + seconds;
        timeStr += (hours >= 12) ? " pm" : " am";
        return timeStr;
    }
//------------------ End of script of Timer Control --------------------
//------------------ Script for Weather and Pray Time ------------------

    $(function () {
       var $weatherTabsVar= $('#weatherParyTabs').tabs({
            fxSlide: true,
            fxFade: true,
            fxSpeed: 'normal', select:0
        });
        viewPrayTime();
    });
    
                //call viewPrayTime on load
            if (window.addEventListener)
                window.addEventListener("load", viewPrayTime, false);

            else if (window.attachEvent)
                window.attachEvent("onload", viewPrayTime);

            else if (document.getElementById)
                window.onload = viewPrayTime;


            function viewPrayTime() {
                var selectedregionValue = document.getElementById('prayRegionsMenu').value.split(',');
                GetSalaTime(selectedregionValue[0], selectedregionValue[1]);
            }
            
            $(document).ready(function(){
	            var cookie = readCookie("WeatherTabStatus");
	            if(cookie != null && cookie != null)
	            {
		            if(cookie=="Pray")
		            {
		                        $(".tab_pray").click()
		            }
		            else
		            {
		                        $(".tab_weather").click()
		            }
	            }
            });
            
//------------------ End of Weather and Pray Time -----------------------
// toggle page
function toggle_visibility(id) {
        var e = document.getElementById('HiddenDiv');
        if (e.style.display == 'block')
            e.style.display = 'none';
        else
            e.style.display = 'block';
    }        
function ChangeTheme(themeName) {
	var themesDivDataContent= $('.ThemesDivData').html();
    var c_value = getCookie("hasatheme");
    if(c_value == "")
    {
      c_value = themeName;   
      }
    var re = new RegExp(c_value, 'g');
  	$("#barLoadJs").html('<script type="text/javascript" id="toolBarJs" src="/ThemesFiles/'+themeName+'/toolBar.js" ></script>');
    $('#loaderJS').attr('src', $('#loaderJS').attr('src').replace(re, themeName).split('?')[0]+"?v="+Math.floor(Math.random()*100));

   $('link[type=text/css][href*='+c_value+']').each(function () {
      $(this).attr('href', $(this).attr('href').replace(re, themeName));
        
  });
    $('input[type=image][src*='+c_value+']').each(function () {
            $(this).attr('src', $(this).attr('src').replace(re, themeName));        
    });
    $('img[src*='+c_value+']').each(function () {        
            $(this).attr('src', $(this).attr('src').replace(re, themeName));        
    });

    $('.VisLibIFrame').contents().find('link[type=text/css]').each(function () {
        if ($(this).attr('href').indexOf(c_value) != -1) {
            $(this).attr('href', $(this).attr('href').replace(re, themeName));
        }
    });
    
   
    //print tabs
    //********************
    //********************
    //********************
    //********************
    
    if (getCookie('lcid')==1025){
    $('#_printTabButton').unbind('click');
    $('#_printTabButton').removeAttr('onclick');
    $('#_printTabButton').click(function() { printTabsContent('rtl','/ThemesFiles/'+themeName+'/style1.css'
    ,
    document.getElementById('ctl00_PlaceHolderMain_view_UC1_HiddenField1').value
   )
 });
    
    }
    else{
    
    $('#_printTabButton').unbind('click');
    $('#_printTabButton').removeAttr('onclick');
    $('#_printTabButton').click(function() { printTabsContent('ltr','/ThemesFiles/'+themeName+'/style_en.css'
        ,
    document.getElementById('ctl00_PlaceHolderMain_view_UC1_HiddenField1').value
    )
 });
  

    }
   
    
    //********************
    //********************
    //********************
    //********************
    //********************
if (getCookie('lcid')==1025){
    $('#_printButton').unbind('click');
    $('#_printButton').removeAttr('onclick');
    $('#_printButton').click(function() { printContent('rtl','/ThemesFiles/'+themeName+'/style1.css') });
    
    }
    else{
    
    $('#_printButton').unbind('click');
    $('#_printButton').removeAttr('onclick');
    $('#_printButton').click(function() { printContent('ltr','/ThemesFiles/'+themeName+'/style_en.css') });

    }
    createCookie("hasatheme", themeName, 500);
    $('.ThemesDivData').html(themesDivDataContent);
   }
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
//-----
function supressSubmitWraper() { _spSuppressFormOnSubmitWrapper = true; }
function HideStartupMessage(){try{$(".beta_container").animate({ top: "-50px"}, 1000 );$(".experment").show();createCookie("StartUpStatmentHidden",true,0); $('.experment').show();}catch(ex){}}
function ChangeSize(textSize){			
createCookie("FontSize",textSize,365);
$(".SubKTitle").animate({ fontSize: textSize+"px"}, 5 );		
$(".Internal-page").not("#linksTable a").animate({ fontSize: textSize+"px"}, 5 );
$(".resizable").not("#linksTable a,.Marsad_menu a").animate({ fontSize: textSize+"px"}, 5 );
$(".resizable a").not("#linksTable a,.Marsad_menu a").animate({ fontSize: textSize+"px"}, 5 );
$(".header_background_image").animate({ fontSize: textSize+"px"}, 5 );
$(".BreadCrumb").animate({ fontSize: textSize+"px"}, 5 );
$(".Internal-page-marsad").animate({ fontSize: textSize+"px"}, 5 );	
$(".Newtitle").animate({ fontSize: textSize+"px"}, 5 );	
$(".Grid-view th,.Grid-view td").not(".A-Small,.A-Medium,.A-Large").animate({ fontSize: textSize+"px"}, 5 );	
$(".ms-acal-month-top span").animate({ fontSize: textSize+"px"}, 5 );	
$(".ms-acal-summary-dayrow td div nobr").animate({ fontSize: textSize+"px"}, 5 );	
$(".ms-acal-display").animate({ fontSize: textSize+"px"}, 5 );	
$(".Emergency p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Government p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Health  p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Education p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Entertainment p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Transportation p").animate({ fontSize: textSize+"px"}, 5 );	
$(".Banks p").animate({ fontSize: textSize+"px"}, 5 );	
}
//----------------------- NumbersOnly ----------------------
// Allow only numbers to be written in textboxes
/*
$(document).ready(function () {


	$(".NumbersOnly").live("keydown", function (e) {
		var key = e.charCode || e.keyCode || 0;
		return (
                isControlKey(key) || // controls keys
                (key >= 48 && key <= 57) || // numbers
                (key >= 96 && key <= 105) // num pad numbers
			);
	});

	// Allow only numbers to be pasted in numeric textboxes
	$(".NumbersOnly").live("input paste", function () {
		var text = $(this).val();
		var newText = "";

		for (var i = 0; i < text.length; i++) {
			if (text[i] >= 0 && text[i] <= 9) {
				newText += text[i];
			}
		}

		if (text != newText) {
			$(this).val(newText);
		}
	});
	});*/
	
//-------------------------- National ID ---------------------------
       function isValidNationalID(sNin) {

        if (null != sNin) {
            if (sNin.length != 10 && sNin.length != 11) {
                flag = false;
            }
            ninNo = parseInt(sNin);
        }
        else {
            flag = false;
        }

        var noLength = sNin.length;
        var divideNo = 10;
        var multNo1 = 2;
        var multNo2 = 1;
        var counter1 = 0;
        var counter2 = 0;
        var tempNin = 0;
        var sum = 0;
        var sum1 = 0;
        var lastNo = 0;
        var chkDigit = 0;
        var workNo = parseInt(ninNo / divideNo);

        for (counter1 = 0; counter1 < noLength; counter1++) {
            tempNin = 0;
            tempNin += workNo % divideNo;
            if (counter1 % 2 == 0)
                tempNin *= multNo1;
            else
                tempNin *= multNo2;

            sum1 = 0;
            if (tempNin > 9) {
                for (counter2 = 0; counter2 < 2; counter2++) {
                    sum1 += tempNin % divideNo;
                    tempNin = parseInt(tempNin / divideNo);
                }
            } else {
                sum1 = tempNin;
            }
            sum += sum1;
            workNo = parseInt(workNo / divideNo);
        }

        chkDigit = sum % divideNo;
        if (chkDigit > 9 || chkDigit != 0)
            chkDigit = divideNo - chkDigit;
        lastNo += ninNo % divideNo;
        if (lastNo == chkDigit) {
            //alert ("lastNo is="+lastNo+"\nchkDigit ="+chkDigit);
            flag = true;
        } else {
            flag = false;
        }
        if (flag == false) {
            return false;
        } else {
            return true;
        }
    }
