
// Preloading Images
var NewImgs = new Array('../Image/barAll1.gif',
'../Image/TitleAr1.gif',
'../Image/TitleEn1.gif',
'../Image/ByAra1.gif',
'../Image/ByEng1.gif',

"../Image/Menue/homeA.gif",
"../Image/Menue/ExhibA.gif",
"../Image/Menue/GALLERYA.gif",
"../Image/Menue/MailListA.gif",
"../Image/Menue/ProductsA.gif",
"../Image/Menue/TUTORIALSA.gif",
"../Image/Menue/VBookA.gif",

"../Image/Menue/homeE.gif",
"../Image/Menue/ExhibE.gif",
"../Image/Menue/GALLERYE.gif",
"../Image/Menue/MailListE.gif",
"../Image/Menue/ProductsE.gif",
"../Image/Menue/TUTORIALSE.gif",
"../Image/Menue/VBookE.gif",

"../Image/Line1.gif",
"../Image/Line2.gif",
"../Image/Line3.gif",
"../Image/Line4.gif",

"../Image/ZCL.png",
"../Image/ZL.png",
"../Image/ZR.png",
"../Image/ZL1.png",
"../Image/ZL2.png",
"../Image/ZR1.png",
"../Image/ZR2.png",
"../Image/CL1.png",
"../Image/CLL1.png",
"../Image/CR1.png",


"../Image/CLR1.png",
"../Image/CL2.png",
"../Image/CR2.png",
"../Image/CLB2.png",
"../Image/CLLB.png",
"../Image/CRB1.png"


);



var imgLen = NewImgs.length;
var loaded = new Array(), preImages = new Array(), currCount = 0, pending = 0;

function loadImages() {
	for (i = 0; i < imgLen; i++) {
		preImages[i] = new Image();
		preImages[i].src = NewImgs[i];
		loaded[i] = 0;
		
	}
	
//	checkLoad();
}

function checkLoad() {
	if (currCount == imgLen) { setTimeout("Wait_fadeOut()",1000); return; }
	for (i = 0; i < imgLen; i++) {
		if (!loaded[i] && preImages[i].complete) {
			loaded[i] = 1; pending++; currCount++;
			checkLoad();
			return;
		}
	}
	setTimeout("checkLoad()",10);
}



////////// other functions


function Fade_In(){

  $(document).ready(function(){
							 
	$("#Wait").css("marginTop",240);						 
    $("#Wait").fadeIn(1000,function(){
									setTimeout("checkLoad()",1500)
									});
	
  });

setTimeout("loadImages()",1200)


}



function Wait_fadeOut(){
	
  $(document).ready(function(){
    $("#Wait").fadeOut(1500,function(){
									
									//$("#All").show();
									$("#footerlayer").show();
									
									setTimeout("fadeinSides()",10);
									
									});
	
	
  });
	
}





 
 
 function fadeinSides(){

var Layers = new Array('hedder1','footerlayer','MainContainer','All')

	

		for (i = 0; i < Layers.length; i++) {
			
				 
				// $("#"+Layers[i]+"").css("backgroundImage","url("+this_image_url+")");
				 
				
			$("#"+Layers[i]+"").fadeIn(1500);

	}

	setTimeout("fadeinContent();",700)
	 }
 

 function fadeinSides2(){
//$("#All").show();
$("#footerlayer").show();


var Layers = new Array('hedder1','footerlayer','MainContainer3','MainContainer','All','MainContainer2')

	
		for (i = 0; i < Layers.length; i++) {
			
				
			$("#"+Layers[i]+"").fadeIn(1500);

	}

	setTimeout("fadeinContent();",700)
	 }
 
function fadeinContent(){
	
	$("#Barcode").css("backgroundImage","url('../Image/barAll1.gif')");
    $("#ByEnglish").css("backgroundImage","url('../Image/ByEng1.gif')");
    $("#ByArabic").css("backgroundImage","url('../Image/ByAra1.gif')");
	


var Layers = new Array('MainContainer_E2','VistTL','VistTC','VistTR','VistBL','VistBC','VistBR','CopyRight','Barcode','ByEnglish','ByArabic','A1','A2','A3','A4','A5')

	
		for (i = 0; i < Layers.length; i++) {
			
				
			$("#"+Layers[i]+"").fadeIn(1500);

	}
	
   // $("#MainContainer_E2").fadeIn(1500);


}



var ImageStep=0
var T = new Array('imagecont')

function TutorialImageSlide(){
	
		if($("#imagecont2").css('display')=='none'){
			$("#imagecont2").css("backgroundImage","url('"+TutoImages[ImageStep]+"')");
			$("#textcont2").replaceWith("<div id='textcont2' style='width:314px; height:130px; position:absolute; display:none ; padding-left:8px'>"+TutoText[ImageStep]+"</div>");
			
			
			$("#imagecont2").fadeIn(1000);
			$("#textcont2").fadeIn(1000);
			$("#textcont1").fadeOut(1000);
			$("#imagecont1").fadeOut(1000,function(){
						
						$("#imagecont1").css("backgroundImage","url('"+TutoImages[(ImageStep + 1)]+"')");
									
				});
		 	}else{
				
			$("#imagecont1").css("backgroundImage","url('"+TutoImages[ImageStep]+"')");
			
			
			$("#textcont1").replaceWith("<div id='textcont1' style='width:314px; height:130px; position:absolute; display:none; padding-left:8px'>"+TutoText[ImageStep]+"</div>");
			$("#textcont1").fadeIn(1000);
			$("#textcont2").fadeOut(1000);
			
			
			$("#imagecont1").fadeIn(1000);
			
			$("#imagecont2").fadeOut(1000,function(){
						
						$("#imagecont2").css("backgroundImage","url('"+TutoImages[(ImageStep + 1)]+"')");
									
				});
				
				
				}	
		

}


var TextStep = 0
function TextSlide(){
	if (i == TutoText.length-1) {
		i = 0
		}
	else{
		i++
		}
	
	//textcont.filters[0].apply();
	//textcont.innerHTML = TutoText[TextStep];
	//textcont.filters[0].play();
}




function ForwSlide(){
if (ImageStep<TutoImages.length-1)
	ImageStep=ImageStep+1
	else
	ImageStep=0;
	TutorialImageSlide()
if (TextStep == TutoText.length-1) {
	TextStep = 0
	}
	else{
		TextStep++
	}
TextSlide()

}


function BackwSlide(){
ImageStep=ImageStep-1
if (ImageStep<0)
ImageStep=0;
TutorialImageSlide()
TextStep=TextStep-1
if (TextStep <0) {
	TextStep = 0
	}
TextSlide()
}

function FirstSlide(){
ImageStep=0;
TutorialImageSlide()
TextStep = 0;
TextSlide()
}




