﻿jQuery(document).ready(function(){
		var selTab = getValue('tab');
		if(selTab == "2" || selTab == "3" || selTab == "4")
		{
			changeTab(selTab);
		}
});
function getValue2(varname)
{
	try{
	var url = window.location.href;
	var qparts = url.split("_");
	if (qparts.length == 0)
	{
		return "";
	}
	return qparts[1];
	}
	catch(err){
	return '1';
	}
}
function getValue(varname)
{
	try{
	var url = window.location.href;
	var qparts = url.split("?");
	if (qparts.length == 0)
	{
		return getValue2(varname);
	}
	var query = qparts[1];
	var vars = query.split("&");
	var value = "";
	for (i=0;i<vars.length;i++)
	{
		var parts = vars[i].split("=");
		if (parts[0] == varname)
		{
			value = parts[1];
			break;
		}
	}
	value = unescape(value);
	value.replace(/\+/g," ");
	value = value.split("#");
	return value[0];
	}
	catch(err){
		return getValue2(varname);
	}
}
var oldTab = "1";
function changeTab(newT){
		if(newT == oldTab){
		}
		else{
		if(oldTab == 3)
		{
			window.document.getElementById("t"+ oldTab).style.display = "none";
		}
		else
		{
			if($.browser.msie)
			{
				$("#t"+ oldTab).hide();
			}
			else
			{
				window.document.getElementById("t"+ oldTab).style.height = "0px";
				window.document.getElementById("t"+ oldTab).style.visibility = "hidden";
			}
		}
		if(newT == 3)
		{
			window.document.getElementById("t"+	newT).style.display = "block";
		}
		else
		{
			if($.browser.msie)
			{
				$("#t"+	newT).show();
			}
			else
			{
				window.document.getElementById("t"+	newT).style.display = "block";
				window.document.getElementById("t"+ newT).style.height = "auto";
				window.document.getElementById("t"+ newT).style.visibility = "visible";
			}
		}
		switch(newT)
		{
			case "1":window.document.getElementById("tab"+ newT).className = "tabdown_1";break;
			case "2":window.document.getElementById("tab"+ newT).className = "tabdown_2";break;
			case "3":window.document.getElementById("tab"+ newT).className = "tabdown_3";break;
			case "4":window.document.getElementById("tab"+ newT).className = "tabdown_4";break;
		}
		switch(oldTab)
		{
			case "1":window.document.getElementById("tab"+ oldTab).className = "tab_1";break;
			case "2":window.document.getElementById("tab"+ oldTab).className = "tab_2";break;
			case "3":window.document.getElementById("tab"+ oldTab).className = "tab_3";break;
			case "4":window.document.getElementById("tab"+ oldTab).className = "tab_4";break;	
		}
		oldTab = newT;
		}
};

			$(function(){
				$('#news').ready(function(){
		$(".portlet-content").toggle();
		$('#loading').hide();
		$('#news').fadeIn();
});
				$('#hazard_popup').dialog({
					autoOpen: false,
					width: 590,
					height: 530,
					modal: true,
					resizable: 'false',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						},
						"إقرأ المزيد في النشرة الجوية":function() {
							$(this).dialog("close");
							changeTab('3');
						},
						"إشترك بخدمة ال-SMS لتكون أول من يعلم": function() { 
							$(this).dialog("close");
							$('#dialog').dialog('open');
						}
					}
				});
				$('#dialog').dialog({
					autoOpen: false,
					width: 400,
					modal: true,
					show: 'drop',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						}
					}
				});
				$('#under').dialog({
					autoOpen: false,
					width: 400,
					modal: true,
					show: 'slide',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						}
					}
				});
				$('#adv').dialog({
					autoOpen: false,
					width: 550,
					height: 350,
					modal: true,
					show: 'slide',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						}, "Radio Zad":function() {
							window.open("http://www.radiozad.com");
						}
					}
				});
					$('#dialogm').dialog({
					autoOpen: false,
					width: 646,
					modal: true,
					show: 'drop',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						}
					}
				});
							$('#j').dialog({
					autoOpen: false,
					width: 420,
					height: 500,
					modal: true,
					show: 'slide',
					buttons: {
						"إغلاق": function() { 
							$(this).dialog("close"); 
						}, "صوّت":function() {
							window.open("http://peaceuntojerusalem.com/index.php");
						}
					}
				});
				// Dialog Link
				$('#Main_Button_Mobile').click(function(){
					$('#dialog').dialog('open');
					return false;
				});

				
				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
				$("#accordion").accordion({ header: "h3", autoHeight: false  });
				
				/*$('#Main_Button_10').click(function(){
					$('#under').dialog('open');
					return false;
				});*/

				
				$(".column").sortable({
					connectWith: '.column'
				});
		
				$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
					.find(".portlet-header")
						.addClass("ui-widget-header ui-corner-all")
						.prepend('<span class="ui-icon ui-icon-plusthick"></span>')
						.end()
					.find(".portlet-content");
		
				$(".portlet-header").click(function() {
					$(this).toggleClass("ui-icon-minusthick");
					$(this).parents(".portlet:first").find(".portlet-content").toggle();
				});
		
				$(".column").disableSelection();
				$(".portlet-content:gt(0)").toggle();
			});