$(document).ready(function() {
var dateshow=new Date();
var day=dateshow.getDate();
var Year=dateshow.getUTCFullYear();
var Armonth=new Array(12);
Armonth[0]='يناير';
Armonth[1]='فبراير';
Armonth[2]='مارس';
Armonth[3]='أبريل';
Armonth[4]='مايو';
Armonth[5]='يونيو';
Armonth[6]='يوليو';
Armonth[7]='أغسطس';
Armonth[8]='سبتمبر';
Armonth[9]='أكتوبر';
Armonth[10]='نوفمبر';
Armonth[11]='ديسمبر';
var month=Armonth[dateshow.getMonth()];
$('.date_show').html(day+' - '+month+' - '+Year);

//moaqet
var path = 'http://www.islamicfinder.org/prayer_service.php?country=saudi_arabia&city=riyadh_region&state=10&zipcode=&latitude=23.3333&longitude=45.3333&timezone=3.00&HanfiShafi=1&pmethod=4&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=0&simpleFormat=xml';
requestCrossDomain(path, function(results) {
var coders=results.replace('<?xml version="1.0"?>','');  
coders=coders.replace('<prayer>','<div style="padding-top:15px;">');
coders=coders.replace('</prayer>','</div>');	
coders=coders.replace('<fajr>','<div style="text-align:justify;">الفجر : ');
coders=coders.replace('</fajr>','</div>'); 
coders=coders.replace('<sunrise>','<div style="text-align:justify;">الشروق : '); 
coders=coders.replace('</sunrise>','</div>'); 
coders=coders.replace('<dhuhr>','<div style="text-align:justify;">الظهر : '); 
coders=coders.replace('</dhuhr>','</div>');
coders=coders.replace('<asr>','<div style="text-align:justify;">العصر : ');
coders=coders.replace('</asr>','</div>');
coders=coders.replace('<maghrib>','<div style="text-align:justify;">المغرب : ');
coders=coders.replace('</maghrib>','</div>');
coders=coders.replace('<isha>','<div style="text-align:justify;">العشاء : '); 
coders=coders.replace('</isha>','</div>');
coders=coders.replace('<date>','<div style="display:none">');
coders=coders.replace('</date> ','</div>');
coders=coders.replace('<hijri>','<div style="display:none">');
coders=coders.replace('</hijri> ','</div>');
coders=coders.replace('<city>','<div style="display:none">');
coders=coders.replace('</city> ','</div>');
coders=coders.replace('<country>','<div style="display:none">');
coders=coders.replace('</country>','</div>'); 
coders=coders.replace('<website>','<div style="display:none">');
coders=coders.replace('</website> ','</div>');
  $('.moaqet').html(coders);
	});

function requestCrossDomain( site, callback ) {
	if ( !site ) {
  $('.moaqet').html('اختر مدينة');
		return false;
	}
	
	yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + site + '"') + '&format=xml&callback=?';

	$.getJSON(yql, function(data) {
		if ( data.results[0] ) {
			data = data.results[0].replace(/<script[^>]*>[\s\S]*?<\/script>/g,'');
			
			if ( typeof callback === 'function' ) {
				callback(data);
			}
		}
		
		else throw new Error('Nothing returned from getJSON.');
	});	
}

//Weather
$.simpleWeather({
				zipcode: 'SAXX0017',
				unit: 'c',
				success: function(weather) {
				var crrr=weather.currently;
					$(".weather").append('<div style="padding-left: 30px;width:200px;min-height:100px;background:transparent url('+weather.image+') no-repeat 0px -10px"><div style="padding-top:40px;">العظمى : '+weather.high+' '+weather.units.temp+'<br />الصغرى : '+weather.low+' '+weather.units.temp+'</div><div style="padding-left:10px;padding-top:50px;width:180;text-align:left;">الان '+weather.temp+' '+weather.units.temp+'</div></div>');
					},
				error: function(error) {
					$(".weather").html('<p>'+error+'</p>');
				}
			});
	});
