﻿// JavaScript Document
// JavaScript Document

var lang ='Heb'
var lastLang ='Heb'

var arrLangDep = new Array;
var arrLangDepHeb = new Array;
arrLangDepEng= ['BEFORE','AFTER','FULL INFORMATION','close','The Challenge','The Insight','Brand Identity','Results','My Name:','My E-Mail:','Title:','Message:','SEND','View the work in the Portfolio','Attach file:','SUBSCRIBE','<strong>NEWSLETTER / OPEN NOW</strong><br>Subscribe and get all the updates about completed brandings, different activities, our success stories <br>and more.']
arrLangDepHeb= ['לפני','אחרי','אינפורמציה מלאה','סגור','האתגר','התובנה','השפה הויזואלית','תוצאות','השם שלי:','האימייל שלי:','כותרת:','הודעה:','שלח','לצפייה בעבודה בתיק העבודות','צרף קובץ:','הרשמו','<strong>ניזולטר / OPEN NOW</strong><br>הרשמו וקבלו את כל העידכונים על תהליכי המיתוג<br> שהושלמו, הפעילויות השונות, סיפורי ההצלחה<br> שלנו ועוד.']
arrLangDepChn= ['设计前','设计后','详细资料','关闭','挑战','洞察力','品牌识别','结果','姓名:','电子邮件:','标题:','留言:','发送','请参阅业务资料中的设计案例','上传文件：',,'SUBSCRIBE']
function changeLang(d,newLang) {
//* 	change styles **/
	if (!d.styleSheets) return;
		var theRules = new Array();
		if (newLang != 'Heb') {
			d.body.direction = 'ltr'
		} else {
			d.body.direction = 'rtl'
		}
		$("Lang"+newLang).style.display = 'none'
		$("Lang"+lastLang).style.display = ''
		lang = newLang
		for (j=0;j<d.styleSheets.length; j++) {
			if (d.styleSheets[j].cssRules) 
				theRules = d.styleSheets[j].cssRules
			else if (d.styleSheets[j].rules) 
				theRules = d.styleSheets[j].rules
				else return;
			for (i=0;i<theRules.length; i++) {
				if (theRules[i].style != null) {
					if (newLang == 'Heb' || lastLang == 'Heb') {
						cssTxt = theRules[i].style.cssText
						placeOfFloat = cssTxt.toLowerCase().indexOf("float")
	
						if ( placeOfFloat != -1) {
							EndOfFitExp = cssTxt.indexOf(";",placeOfFloat)
							if (EndOfFitExp==-1) {
								EndOfFitExp=cssTxt.length
							}
							if (cssTxt.substring(placeOfFloat,EndOfFitExp).indexOf("right")>0) {
								newFloat = 'left'
							} else {
								newFloat = 'right'
							}
							NewString = cssTxt.substring(0,placeOfFloat) + "float: "+newFloat
							if (EndOfFitExp != -1 ) {
								NewString = NewString + cssTxt.substr(EndOfFitExp,cssTxt.length)
							}
							theRules[i].style.cssText=NewString
						}			
						if (parseInt(theRules[i].style.marginLeft) != null) {
							tmpRight = theRules[i].style.marginRight
							theRules[i].style.marginRight = theRules[i].style.marginLeft
							theRules[i].style.marginLeft = tmpRight				
						}
						if (parseInt(theRules[i].style.left) != null) {
							tmpRight = theRules[i].style.right
							theRules[i].style.right = theRules[i].style.left
							theRules[i].style.left = tmpRight				
						}
						if (parseInt(theRules[i].style.paddingLeft) != null) {
							tmpRight = theRules[i].style.paddingRight
							theRules[i].style.paddingRight = theRules[i].style.paddingLeft
							theRules[i].style.paddingLeft = tmpRight
						}
						if (theRules[i].style.textAlign != null) {
							if (theRules[i].style.textAlign == "right") {
								theRules[i].style.textAlign = "left"
							} else {
								if (theRules[i].style.textAlign == "left") {
									theRules[i].style.textAlign = "right"
								}
							}
						}
//						if (theRules[i].selectorText == '#Lang' || theRules[i].selectorText  == '*[ID"Lang"]') {
//							if (lang == 'Heb') {
//								theRules[i].style.paddingRight = '71px'
//							} else {
//								theRules[i].style.paddingLeft = '22px'
//							}
//						}
						
						if (theRules[i].selectorText == '#header' || theRules[i].selectorText  == '*[ID"header"]') {
							if (lang == 'Heb') {
								theRules[i].style.right = '3px'
							} else {
								theRules[i].style.left = '3px'
							}
						}
						if (theRules[i].selectorText == '#MainHeader' || theRules[i].selectorText  == '*[ID"MainHeader"]') {
							if (lang == 'Heb') {
								theRules[i].style.marginLeft = '22px'
							} else {
								theRules[i].style.marginRight = '22px'
							}
						}
											
						if (theRules[i].style.direction == 'rtl') {
							theRules[i].style.direction = 'ltr'
						} else {
							if ((theRules[i].style.direction == 'ltr') && (theRules[i].selectorText != '#StrpImages' && theRules[i].selectorText != '*[ID"StrpImages"]' && theRules[i].selectorText != ".AboutDataBackground" && theRules[i].selectorText != ".ProjImagesScroller" && theRules[i].selectorText != ".CaseImagesScroller" && theRules[i].selectorText != ".BackgroundForNews") ) {
								theRules[i].style.direction = 'rtl'
							}
						}
					}
					if (newLang == 'Chn' || lastLang == 'Chn') {
					
						if (theRules[i].selectorText == '.PageText, .PageText a') {
							if (newLang == 'Chn') {
								theRules[i].style.fontSize = "11px"
							} else {
								theRules[i].style.fontSize = "12px"
							}
						}
						if (theRules[i].selectorText == '.ItemsTitle') {
							if (newLang == 'Chn') {
								theRules[i].style.fontSize = "11px"
							} else {
								theRules[i].style.fontSize = "10px"
							}
						}
						if (theRules[i].selectorText == '.AboutPageText, .AboutPageText a') {
							if (newLang == 'Chn') {
								theRules[i].style.fontSize = "14px"
								theRules[i].style.lineHeight = "25px"
							} else {
								theRules[i].style.fontSize = "17px"
								theRules[i].style.lineHeight = "22px"
							}
						}

					}
				}
			}
		}
		// change credits
		if (lang == "Heb") {
			changePic("imgHatayas","images/credits/hatayas.png")
			changePic("imgHatayas_on","images/credits/hatayas_ON.png")
			changePic("imgShual","images/credits/shual.png")
			changePic("imgShual_on","images/credits/shual_ON.png")
		} else {
			changePic("imgHatayas","images/credits/hatayas_e.png")
			changePic("imgHatayas_on","images/credits/hatayas_ON_e.png")
			changePic("imgShual","images/credits/shual_e.png")
			changePic("imgShual_on","images/credits/shual_ON_e.png")
		}
		lastLang = lang
		reloadMenus()
	}
	
	function ReplaceLangDep() {
		for (i=0;i<arrLangDepEng.length;i++){
			if (document.getElementById("LangDep"+i) != null) {
				if (lang =='Heb') {
					document.getElementById("LangDep"+i).innerHTML = arrLangDepHeb[i]
				} else {
					if (lang =='Eng') {
						document.getElementById("LangDep"+i).innerHTML = arrLangDepEng[i]
					} else {
						document.getElementById("LangDep"+i).innerHTML = arrLangDepChn[i]
					}
				}
			}
		}
		if (lang=='Heb') {
			if (document.getElementById("btnPreItem") != null) {
				$("ItemsPre").innerHTML = $("ItemsPre").innerHTML.replace(/Left.png/g,"Right.png")
				$("ItemsNext").innerHTML = $("ItemsNext").innerHTML.replace(/Right.png/g,"Left.png")
			}
			if (document.getElementById("SendArrow") != null) {
				$("SendArrow").innerHTML = $("SendArrow").innerHTML.replace(/Right.png/g,"Left.png")
			}			
		}
	}

var minusLineHeight,minusCrcOffset
function HandleSifrMenusSize(d) {
	j=0
	while (d.styleSheets[j].href.indexOf("general.css") < 0 && j<d.styleSheets.length) {
		j = j+1
	}
	if (d.styleSheets[j].cssRules) 
		theRules = d.styleSheets[j].cssRules
	else if (d.styleSheets[j].rules) 
		theRules = d.styleSheets[j].rules
	for (i=0;i<theRules.length; i++) {
		if (theRules[i].selectorText == ".PageText ") {
			if (lang == "Heb") {
				theRules[i].style.fontSize = "12px"
			} else {
				theRules[i].style.fontSize = "13px"
			}
		}
	}
	
}
