﻿function mycarousel_initCallback(carousel)
		{
 
			jQuery('.jcarousel-control a').bind('click', function() {
					carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
					return false;
				});
		
			// Disable autoscrolling if the user clicks the prev or next button.
			carousel.buttonNext.bind('click', function() {
				carousel.startAuto(0);
			});
		
			carousel.buttonPrev.bind('click', function() {
				carousel.startAuto(0);
			});
		
			// Pause autoscrolling if the user moves with the cursor over the clip.
			carousel.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});
		};
	
		$(document).ready(function(){
			
			jQuery('#banner ul').jcarousel({
				scroll: 1,
				auto: 5,
				wrap: 'last',
				initCallback: mycarousel_initCallback
			});
			
		});
function logout()
 {
 
location ="index.php?do=dologout";
 }
var currentTab = 0; 
function openTab(clickedTab) {
	var thisTab = $(".tabs_menu  a").index(clickedTab);
	$(".tabs_menu  li a").removeClass("active");
	$(".tabs_menu  li a:eq("+thisTab+")").addClass("active");
	$(".tabs_menu .tabbed-content").hide();
	$(".tabs_menu .tabbed-content:eq("+thisTab+")").show();
	currentTab = thisTab;
}
//
$(document).ready(function() {
	$(".tabs li:eq(0) a").css("border-left", "none");

	$(".tabs_menu  li a").click(function() {
		openTab($(this)); return true;
	});

	$(".tabs_menu li a:eq("+currentTab+")").click()
});



$(document).ready(function(){

$(".divClass .deleteDiv").click(function(){
$(this).parents(".divClass").animate({ opacity: 'hide' }, "slow");
});

});



function showhid(id)
{
document.getElementById("hid").style.display="block";
return(id);
}
function hidshow(id)
{
document.getElementById("hid").style.display="none";
return(id);
}

//--
var xmlhttp;

function momiz(str,Gid,divname)
{
document.getElementById ("divname").value=divname;
if (str.length==0)
  {
  document.getElementById(divname).innerHTML="";
  document.getElementById(divname).style.border="0px";
  return;
  }
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
  var Y =document.getElementById ("Y").value;
  if(Y=='0'){str='NotLogin';}
var url="info.php";
url=url+"?do="+str+'&Gid='+Gid;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=state_momiz ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function state_momiz()
{
var DivName=document.getElementById ("divname").value;
var loadstatustext="<img src='loading.gif'/>"

if (xmlhttp.readyState==4)
  {
  document.getElementById(DivName).innerHTML=xmlhttp.responseText;
  document.getElementById(DivName).style.border="0px";
  }
  else
  {
    document.getElementById(DivName).innerHTML=loadstatustext;
  }

}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {

  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {

  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function hideDiv2() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow2').style.visibility = 'hidden';
document.getElementById('bigLoginDiv').style.display = 'none';
    showScroll();

}
else {
if (document.layers) { // Netscape 4
document.hideshow2.visibility = 'hidden';
document.getElementById('bigLoginDiv').style.display = 'none';
    showScroll();


}
else { // IE 4
document.all.hideshow2.style.visibility = 'hidden';
document.getElementById('bigLoginDiv').style.display = 'none';
    showScroll();

}
}
}

function showDiv2(Do,ID,DivName) {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow2').style.visibility = 'visible';
document.getElementById('bigLoginDiv').style.display = 'block';
    scrol = document.body.scroll;
    document.body.scroll = "no";
    document.body.style.overflow = "hidden";
    document.body.scrollIntoView(100);


}
else 
{
if (document.layers) { // Netscape 4
document.hideshow2.visibility = 'visible';
}
else { // IE 4
document.all.hideshow2.style.visibility = 'visible';
document.getElementById('bigLoginDiv').style.display = 'block';


}
}
sama(DivName,Do,ID);
}
function showScroll() {
    document.body.scroll = "yes";
    document.body.style.overflow = "visible";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

}

function aza(mo,sen)
{
	setCookie('mo3len',mo,7);
	setCookie('sender',sen,7);
	showDiv();
var sender=getCookie('sender');
var mo=getCookie('mo3len');
document.send.mo3len.value = mo;
document.send.sender.value = sender;


}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
alert (c_end);
}


function AddText(NewCode) {
        document.POWER.message.value+=NewCode;
        document.POWER.message.focus();
}
function smile(){
        AddTxt=' ~2';
        AddText(AddTxt);
}
function sad(){
        AddTxt=' ~1';
        AddText(AddTxt);
}
function laugh(){
        AddTxt=' ~3';
        AddText(AddTxt);
}
function tongue(){
        AddTxt=' ~4';
        AddText(AddTxt);
}
function shocked(){
        AddTxt=' ~6';
        AddText(AddTxt);
}
function cool(){
        AddTxt=' ~7';
        AddText(AddTxt);
}
function rolleyes(){
        AddTxt=' ~8';
        AddText(AddTxt);
}
function wink(){
        AddTxt=' ~5';
        AddText(AddTxt);
}
function embarassed(){
        AddTxt=' ~9';
        AddText(AddTxt);
}


var xmlhttp;

function mor(str,catid,subcatid,page)
{
if (str.length==0)
  {
  document.getElementById("mor").innerHTML="";
  document.getElementById("mor").style.border="0px";
  return;
  }
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
var url="info.php";
url=url+"?do="+str+'&catid='+catid+'&subcatid='+subcatid+'&page='+page;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=statemor ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function statemor()
{
var DivName='mor';
var loadstatustext="<img src='loading.gif'/>"

if (xmlhttp.readyState==4)
  {
  document.getElementById(DivName).innerHTML=xmlhttp.responseText;
  document.getElementById(DivName).style.border="0px";
  }
  else
  {
    document.getElementById(DivName).innerHTML=loadstatustext;
  }

}


var xmlhttp;

function showResult3030_(str)
{
if (str.length==0)
  {
  document.getElementById("mail").innerHTML="";
  document.getElementById("mail").style.border="0px";
  return;
  }
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
var url="info.php";
url=url+"?do="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged3030_ ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function showResult3030_par33_(str,name,email)
{
if (str.length==0)
  {
  document.getElementById("mail").innerHTML="";
  document.getElementById("mail").style.border="0px";
  return;
  }
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
var url="info.php";
url=url+"?do="+str+'&name='+name+'&email='+email;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged3030_ ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged3030_()
{
var DivName='mail';
var loadstatustext="<img src='img/loading.gif'/>"

if (xmlhttp.readyState==4)
  {
  document.getElementById(DivName).innerHTML=xmlhttp.responseText;
  document.getElementById(DivName).style.border="0px";
  }
  else
  {
    document.getElementById(DivName).innerHTML=loadstatustext;
  }

}

function characters_used (s) {
          var r = s - document.getElementById('commenttxt').value.length;
           document.getElementById('characters').innerHTML = r;
           if (r < 0) {
             document.getElementById('characters').style.color = '#f00';
             document.getElementById('add_txt').disabled = 'disabled';
             document.getElementById('add_txt').className = 'submit_disabled';
             document.getElementById('add_txt_div').className = 'submit_disabled';
           } else {
             document.getElementById('characters').style.color = '#777';
             document.getElementById('add_txt').disabled = '';
             document.getElementById('add_txt').className = 'submit_general';
             document.getElementById('add_txt_div').className = 'submit_general';
           }
  }

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

}

function aza(mo,sen)
{
	setCookie('mo3len',mo,7);
	setCookie('sender',sen,7);
	showDiv();
var sender=getCookie('sender');
var mo=getCookie('mo3len');
document.send.mo3len.value = mo;
document.send.sender.value = sender;


}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
alert (c_end);
}

jQuery(document).ready(function(){
jQuery('.terms').hide();
class_comm = '.text_comment';
if(jQuery(class_comm).val() == '') jQuery(class_comm).val('أضف تعليقك...');
jQuery(class_comm).css('height','58px');
 
 
jQuery(class_comm).focus(function () {
jQuery('.terms').show();
jQuery(class_comm).css('height','180px');
if(jQuery(class_comm).val() == 'أضف تعليقك...') jQuery(class_comm).val('');
});
 
});
 
 function ChkMsg()
 {
  var txt=document.getElementById ("commenttxt").value;

  if(!txt){alert('تاكد من التعليق');}
  else
  {
  			document.POWER.submit(); 
  }
  
	
 }
function Check(chk,vrt)
{
if(document.save.chknone.checked==true)
{
chk.disabled= true;
vrt.disabled= true;
}
else
{
chk.disabled= false;
vrt.disabled= false;

}
}


var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:100, scrollto:'topcontrol', scrollduration:800, fadeduration:[500, 100]},
	controlHTML: '', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
	controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#topcontrol', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

scrolltotop.init()

function ChkMatger()
{
	var title =document.getElementById("title").value ;
	var link =document.getElementById("link").value ;
	if(!title)
	{
	alert("تاكد من عنوان المتجر");document.AddFrm.title.focus(); return false ;
	}	
	else
	if(!link)
	{
	alert("تاكد من رابط المتجر من فضلك");document.AddFrm.link.focus(); return false ;
	}
	else
	{
	return true ;
	}

}

ajax = function(rappel, method, url, flux){
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() :
       (window.ActiveXObject ?  new ActiveXObject("Microsoft.XMLHTTP") : '');

if (xhr) {
        xhr.onreadystatechange = function () {rappel(xhr);}
        xhr.open(method,  url, true);
        xhr.send(flux);
    } else alert("Ajax ?");
}


isReady = function(xhr, f) {
    if ( xhr.readyState == 4) {
                if (xhr.status != 200)
                      {alert('Erreur HHTP :  ' +  xhr.status);}
                else  { f(xhr.responseText); }
        }
}

function insereReponse(r) {

        document.getElementById('mst').innerHTML = r
}


include = function(form){
            url = 'spvot.php?do=show&ID=' + form.part.value +'&depid='+form.depid.value;
for (var i = 0; i < document.form.vote.length; i++) {
  if (document.form.vote[i].checked) {
    url=url+"&vote=" + document.form.vote[i].value;
  }
}

  document.getElementById('mst').innerHTML = '<div align="center"><img src="img/loading.gif" alt="www.egyfanz.com" /> <br /><font style="color:#ffffff; font-size:7pt;"> انتظر قليلا</font> </div>';


     ajax(function (xhr) {isReady(xhr, insereReponse);} , 'POST', url, null);
     return false;
}


$(document).ready(function() {	
 
	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
 
	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			

	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
});

function show(catid)
{
	var RR=eval(document.getElementById("RR").value);	
	document.getElementById(catid+'-'+RR).style.display='block';	
	document.getElementById("RR").value=eval(document.getElementById("RR").value)+1;
}
function showDiv(id)
{
	var Show="show"+id;
	
	
	var chk= document.getElementById(id).checked ;
	if(chk)
	{
	document.getElementById(Show).style.display='block';
	}
	else
	{
	document.getElementById(Show).style.display='none';
	}


}
function Add(id)
{
	var b4=document.getElementById("article"+id+"4").style.display;
	if(b4=='none')
	{
		document.getElementById("article"+id+"4").style.display='block';	
	}else
	{
		document.getElementById("article"+id+"5").style.display='block';	
	}
	
}
function Sub(id)
{
	var b5=document.getElementById("article"+id+"4").style.display;

	if(b5=='none')
	{
		document.getElementById("article"+id+"5").style.display='none';	
	}else
	{
		
		document.getElementById("article"+id+"4").style.display='none';	
	}

}

$(document).ready(function(){
 
	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
 
});

$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("fast");
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("fast");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle div").click(function () {
		$("#toggle div").toggle();
	});		
		
});

$(document).ready(function(){ 	
	  function slideout(){
  setTimeout(function(){
  $("#response").slideUp("slow", function () {
      });
    
}, 2000);}
	
    $("#response").hide();
	$(function() {
	$("#list ul").sortable({ opacity: 0.8, cursor: 'move', update: function() {
			
			//var order = $(this).sortable("serialize") + '&update=update'; 
			
		    var username = 'ashley';
			var order = $(this).sortable("serialize") + '&update=update' + '&username=' + username; 
			
			$.post("updateList.php", order, function(theResponse){
				$("#response").html(theResponse);
				$("#response").slideDown('slow');
				slideout();
				//alert(order);
			}); 															 
		}								  
		});
	});
 
});	



$(document).ready(function(){ 	
	  function slideout2(){
  setTimeout(function(){
  $("#response").slideUp("slow", function () {
      });
    
}, 2000);}
	
    $("#response").hide();
	$(function() {
	$("#listv ul").sortable({ opacity: 0.8, cursor: 'move', update: function() {
			
			//var order = $(this).sortable("serialize") + '&update=update'; 
			
		    var username = 'ashley';
			var order = $(this).sortable("serialize") + '&update=update' + '&username=' + username; 
			
			$.post("updateList.php", order, function(theResponse){
				$("#response").html(theResponse);
				$("#response").slideDown('slow');
				slideout2();
				//alert(order);
			}); 															 
		}								  
		});
	});
 
});	


