var tid;
var logo_loop = false;
var max_logo = 0;
var scroll  = false;
var tis;
var ActivateProjectLink = false;

transeffect = 4;
logo_id = 0;
logos = new Array(7);
logos[0] = "../Images/logo_agis.jpg";
logos[1] = "../Images/logo_beari.jpg";
logos[2] = "../Images/logo_elit.jpg";
logos[3] = "../Images/logo_palkal.jpg";
logos[4] = "../Images/logo_refael.jpg";
logos[5] = "../Images/logo_rotem.jpg";
logos[6] = "../Images/logo_sdl.jpg";

//------------------------------------------
function ChangeImg(){

	if (logo_loop){
	document.all.logo_img.filters.item(0).Apply();
	document.all.logo_img.src = logos[logo_id];
	document.all.logo_img.filters.item(0).Transition = transeffect;
	document.all.logo_img.filters.item(0).Play();

	logo_id+=1;
	if (logo_id == 7) logo_id = 0;
	transeffect+=1;
	if (transeffect == 7) transeffect = 4;

	clearInterval(tid);
	tid = self.setInterval('ChangeImg()',6000);
	}
	return;
}

//------------------------------------------
function ChangeCat(id, lng){
	catid = id;
	L=lng;
//	if(L!='') L = '_'+L;
	logo_loop = false;
	clearInterval(tid);
	document.all.logo_img.src = '../Images/trans.gif';
	switch (catid) 
	{ 
	// agricalture control
		case 1 :
			if(L=='_eng'){
				frm.frame_title.value="Agricalture Control";			
			}
			else{
				frm.frame_title.value="בקרה בחלקאות";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat1_logo.jpg';
			document.all.ifrm.src='../Content/agrec_control_main'+L+'.asp?catid='+catid+'&Lang='+lng;
			break; 
	// automatic check
		case 2 : 
			if(L=='_eng'){
				frm.frame_title.value="Automated Test Stations (ATS)";			
			}
			else{
				frm.frame_title.value="מערכות בדיקה אוטומטית";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat2_logo.jpg';
			document.all.ifrm.src='../Content/Automatc_checks'+L+'.asp?catid='+catid+'&Lang='+lng;
			break; 
	// R&D
		case 3 : 
			if(L=='_eng'){
				frm.frame_title.value="Research and Development";			
			}
			else{
				frm.frame_title.value="מחקר ופיתוח";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat3_logo.jpg';
			document.all.ifrm.src='../Content/R_and_D'+L+'.asp?catid='+catid+'&Lang='+lng;
			break; 
	// industrial control
		case 4:
			if(L=='_eng'){
				frm.frame_title.value="Industrial Control";			
			}
			else{
				frm.frame_title.value="בקרה תעשייתית";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat4_logo.jpg';
			document.all.ifrm.src='../Content/ind_control'+L+'.asp?catid='+catid+'&Lang='+lng;
			break;
	// computers & software
		case 5: 
			if(L=='_eng'){
				frm.frame_title.value="Computerization & Programming";			
			}
			else{
				frm.frame_title.value="מיחשוב ותוכנה";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat5_logo.jpg';
			document.all.ifrm.src='../Content/computers_software'+L+'.asp?catid='+catid+'&Lang='+lng;
			break; 
	// customers
		case 6 : 
			if(L=='_eng'){
				frm.frame_title.value="Our Customers";			
			}
			else{
				frm.frame_title.value="לקוחותינו";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers_active'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/customers_logo1.jpg';
			document.all.ifrm.src='../Content/Customers'+L+'.asp?Lang='+lng;
			logo_loop = true;
			ChangeImg();
			break; 
	// contact us
		case 7 : 
			if(L=='_eng'){
				frm.frame_title.value="Contact us";			
			}
			else{
				frm.frame_title.value="        צור קשר";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus_active'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/ContactUs_logo.jpg';
			document.all.ifrm.src='../Content/ContactUs'+L+'.asp?scroll=2&Lang='+lng;
			break; 
	// company profile
		case 8:
			if(L=='_eng'){
				frm.frame_title.value="Company Profile";
			}
			else{
				frm.frame_title.value="פרופיל חברה";
			}
			frm.img_profile.src='../Images/InnerPage/profile_active'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/profile_logo.jpg';
			document.all.ifrm.src='../Content/company_profile'+L+'.asp?Lang='+lng;
			break; 
	// refet
		case 9:
			if(L=='_eng'){
				frm.frame_title.value="dairy Bams";			
			}
			else{
				frm.frame_title.value="רפתות";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/refet_logo.jpg';
//			document.all.ifrm.src='../Content/agrec_control_refet.asp';
			break; 
	// LuL
		case 10:
			if(L=='_eng'){
				frm.frame_title.value="chicken coops";			
			}
			else{
				frm.frame_title.value="לולים";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat1_logo.jpg';
			break; 
	// hashkaya
		case 11:
			if(L=='_eng'){
				frm.frame_title.value="Irrigation";			
			}
			else{
				frm.frame_title.value="השקיה";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/hashkaya_logo.jpg';
			break; 
	// automatic check
		case 12 : 
			if(L=='_eng'){
				frm.frame_title.value="Aditional Systems";			
			}
			else{
				frm.frame_title.value="מערכות נוספות";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat2_logo.jpg';
			document.all.ifrm.src='../Content/Extra_systems'+L+'.asp?catid='+catid+'&Lang='+lng;
			break; 
		case 14 : 
		case 15 : 
			if(L=='_eng'){
				frm.frame_title.value="Industrial Control";			
			}
			else{
				frm.frame_title.value="בקרה תעשייתית";
			}
			frm.img_profile.src='../Images/InnerPage/profile'+L+'.jpg';
			frm.img_contactus.src='../Images/InnerPage/contactus'+L+'.jpg';
			frm.img_customers.src='../Images/InnerPage/customers'+L+'.jpg';
			document.all.td_logo.background='../Images/InnerPage/Cat4_logo.jpg';
			setPrjImg(4);
			break; 
	// homepage
   		default : 

	} 
	setPrjImg(catid)
}

//------------------------------------------------------
// set the images at the bottom of the page
// to be active according to the active category
function setPrjImg(i){
	frm.img1.src='../Images/InnerPage/agr_control.jpg';
	frm.img2.src='../Images/InnerPage/auto_check.jpg';
	frm.img3.src='../Images/InnerPage/dev_inv.jpg';
	frm.img4.src='../Images/InnerPage/ind_control.jpg';
	frm.img5.src='../Images/InnerPage/comp_soft.jpg';
	switch (i) 
		{ 
			case 1 : 
			case 9 : 
			case 10 : 
			case 11 : 
				frm.img1.src='../Images/InnerPage/agr_control_active.jpg';
				break;
			case 12 : 
				frm.img2.src='../Images/InnerPage/auto_check_active.jpg';
				break;
			case 3 : 
				frm.img3.src='../Images/InnerPage/dev_inv_active.jpg';
				break;
			case 4 :
			case 14 :
			case 15 : 
				frm.img4.src='../Images/InnerPage/ind_control_active.jpg';
				break;
			case 5 :
			case 16 :
			case 17 : 
				frm.img5.src='../Images/InnerPage/comp_soft_active.jpg';
				break;
		}
	//if(i>5) setPrjImg(catid);
}

//------------------------------------------------------
function scrollWin(i){
 	if(i==0){
		window.ifrm.scrollBy(0, -50);
	}else{
		window.ifrm.scrollBy(0, 50);
	}
}

//------------------------------------------------------
function winDown(q,f){
	if(scroll || f>0){
//		scroll=false;
		clearInterval(tis);
		tis = self.setInterval('scrollWin('+q+', 1)',400)
//		scrollWin(q);
	};
}
//------------------------------------------------------
function winDownStop(){
	scroll=false;
	clearInterval(tis);
}
//------------------------------------------------------
function setMarging(){
document.body.style.marginLeft =(screen.availWidth-750)/2 + 'px';
}
//------------------------------------------------------
function checkStandardForm(frm){
	var f = frm;
	for(var i=0;i<f.length;i++){
		if((f(i).type=='text' || f(i).type=='textarea') && f(i).value==''){
			alert("you must fill in all text areas");
			f(i).focus();
			return false;
			}
	}
}
//------------------------------------------------------
function CreateTextareaEditor(frm){
	var f = frm;
	for(var i=0;i<f.length;i++){
		if(f(i).type=='textarea'){
//			alert(f(i).name);
			editor_generate(f(i).name);
		}
	}
}
//------------------------------------------------------
function ProjectHref(cid, Lng){
	if(ActivateProjectLink){
	  window.open('../content/ShowProjectsPerCat.asp?catid='+catid+'&Lang='+Lng ,'_new','menubar=0, resizable=1, width=750, toolbar=1, scrollbars=1');
	}
}