
﻿
var myXML;var formXML;var startupXML;var selectedFontID=null;var selectedWeight=null;var openDropDown="";var PrevBtnClicked=null;function loadFont(fontID){var menuElement=document.getElementById("mb_"+fontID);var selectedFontElement=document.getElementById("mb_"+selectedFontID);var BottomMenuElement=document.getElementById("bmb_"+fontID);var BottomselectedFontElement=document.getElementById("bmb_"+selectedFontID);if(selectedFontElement!=null){$(selectedFontElement).css("display","none");BottomselectedFontElement.className=BottomselectedFontElement.className.replace("_On","_Off");}
$(menuElement).css("display","block");BottomMenuElement.className=BottomMenuElement.className.replace("_Off","_On");selectedFontID=fontID;selectedWeight=null;var fontNode=$(myXML).find("//fonts/font[fontID='"+fontID+"\']");var weightsNode=fontNode.find("weights");$("#WeightsHeaderDiv").removeClass($("#WeightsHeaderDiv").attr("class"));$("#WeightsHeaderDiv").addClass("TheWeightsHeader_"+weightsNode.attr("type"));var isFirst=true;var isFirstItalic=true;var firstWeight="";var startupWeight="";var weightMenuHtml="";var weightMenuItalicHtml="";var weights=fontNode.find("weight").each(function(){var weight=$(this);if(weight.attr("systemName").indexOf("italic")==-1)
{if(isFirst){isFirst=false;firstWeight=weight.attr("systemName");}
else{weightMenuHtml+=" | ";}
weightMenuHtml+="<span class=\"WeightBtn_Off\" id=\"wb_"+weight.attr("systemName")+"\" onclick=\"loadWeight(\'"+fontID+"\',\'"+weight.attr("systemName")+"\',this);\">";weightMenuHtml+=weight.attr("title");weightMenuHtml+="</span>";}else{if(isFirstItalic){isFirstItalic=false;firstWeight=weight.attr("systemName");}
else{weightMenuItalicHtml+=" | ";}
weightMenuItalicHtml+="<span class=\"WeightBtn_Off\" id=\"wb_"+weight.attr("systemName")+"\" onclick=\"loadWeight(\'"+fontID+"\',\'"+weight.attr("systemName")+"\',this);\">";weightMenuItalicHtml+=weight.attr("title");weightMenuItalicHtml+="</span>";}
if(weight.attr("startUp")=="true")
{startupWeight=weight.attr("systemName");}});$(document.getElementById("WeightsButtonsDiv")).html(weightMenuHtml);$(document.getElementById("WeightsButtonsDivItalic")).html(weightMenuItalicHtml);if(!isFirst||!isFirstItalic){if(startupWeight=="")
{loadWeight(fontID,firstWeight,document.getElementById("wb_"+firstWeight));}else{loadWeight(fontID,startupWeight,document.getElementById("wb_"+startupWeight));}}}
function loadWeight(fontID,systemName,currWeight){if(selectedWeight!=null){selectedWeight.className=selectedWeight.className.replace("_On","_Off");}
currWeight.className=currWeight.className.replace("_Off","_On");document.getElementById("fontImage").src="files/fonts/"+fontID+"/"+systemName+".gif";selectedWeight=currWeight;}
var numOfDropDowns;var DropDowns;function changeBgImage(image,id){document.getElementById(id).style.backgroundImage='url('+image+')';}
function getParentObject(Element){var parentEl=Element.parentElement;if(parentEl==null){parentEl=Element.parentNode;}
return parentEl;}
function fontBtnOn(Element){parentEl=getParentObject(Element);parentEl.className=parentEl.className.replace('_Off','_On');}
function fontBtnOff(Element){parentEl=getParentObject(Element);parentEl.className=parentEl.className.replace('_On','_Off');}
function OpenPopup(ElementID,BackgroundID,speed){if($("#"+ElementID).context.popupStatus==null){$("#"+ElementID).context.popupStatus=0;}
if(BackgroundID!=""){$("#"+BackgroundID).css({"opacity":"0.7"});$("#"+BackgroundID).fadeIn(speed);}
$("#"+ElementID).fadeIn(speed);$("#"+ElementID).context.popupStatus=1;}
function getYOffset(){var pageY;if(typeof(window.pageYOffset)=='number'){pageY=window.pageYOffset;}
else{pageY=document.documentElement.scrollTop;}
return pageY;}
function getXOffset(){var pageX;if(typeof(window.pageXOffset)=='number'){pageX=window.pageXOffset;}
else{pageX=document.documentElement.scrollLeft;}
return pageX;}
function CenterPopup(ElementID,BackgroundID,fixedTop){var windowWidth=document.documentElement.clientWidth;var windowHeight=document.documentElement.clientHeight;var popupHeight=$("#"+ElementID).height();var popupWidth=$("#"+ElementID).width();var topOffset;if(fixedTop)
{topOffset=20;}
else
{topOffset=(windowHeight/2-popupHeight/2)+getYOffset();if(topOffset<0){topOffset=0;}}
$("#"+ElementID).css({"position":"absolute","top":topOffset,"left":windowWidth/2-popupWidth/2});$("#"+BackgroundID).css({"height":windowHeight});}
function ClosePopup(ElementID,BackgroundID,speed){if(BackgroundID!=""){$("#"+BackgroundID).fadeOut(speed);}
$("#"+ElementID).fadeOut(speed);$("#"+ElementID).context.popupStatus=0;}
function getFontsXML(fn)
{getXML("fonts.xml",function(){loadRandomFont();if(fn!=null){fn();}},function(value){myXML=value;});}
function getFormXML(fn){getXML("form.xml",fn,function(value){formXML=value;});}
function getXML(fileName,fn,setFn)
{if(myXML==null){$.get(fileName,{},function(xml){setFn(xml);if(fn!=null){fn();}});}
else
{if(fn!=null)
{fn();}}}
function loadRandomFont()
{$.get("startupfonts.xml",{},function(xml){startupXML=xml;var count=0;$(startupXML).find("font").each(function(){count++;});var rand_no=Math.floor(Math.random()*count);var SelectedNode=$(startupXML).find("font")[rand_no];loadFont($(SelectedNode).attr('fontID'));});}
function EnableCssClasHover(ClassName)
{$("."+ClassName+"_on").hover(function(){$("."+ClassName).css('display','none');},function(){$("."+ClassName).css('display','block');});}
$(document).ready(function(){getFontsXML();$("#OrderMe").click(function(){CenterPopup("OrderOnlineForm","backgroundPopup",true);OpenPopup("OrderOnlineForm","backgroundPopup","slow");});$("#OrderMe").hover(function(){$("#OrderMe").removeClass('OrderMe').addClass('OrderMeHover');},function(){$("#OrderMe").removeClass('OrderMeHover').addClass('OrderMe');});EnableCssClasHover("TwitterTitleDiv");EnableCssClasHover("BlogTitleDiv");EnableCssClasHover("FontsInActionTitleDiv");EnableCssClasHover("AboutDiv");EnableCssClasHover("EMailLinkDiv");EnableCssClasHover("CatalogDiv");$("#CloseOrderForm").click(function(){ClosePopup("OrderOnlineForm","backgroundPopup","slow");});$("#backgroundPopup").click(function(){ClosePopup("OrderOnlineForm","backgroundPopup","slow");});$("#spTermsOfUse").click(function(){CenterPopup("TermsOfUse","TermsOfUseBackground",false);OpenPopup("TermsOfUse","TermsOfUseBackground","slow");});$(window).resize(function(){CenterPopup("OrderOnlineForm","backgroundPopup",true);CenterPopup("TermsOfUse","TermsOfUseBackground",false);CenterPopup("About","AboutBackground",false);});$("#TermsOfUseBackground").click(function(){ClosePopup("TermsOfUse","TermsOfUseBackground","slow");});$("#CloseTerms").click(function(){ClosePopup("TermsOfUse","TermsOfUseBackground","slow");});$("#CloseAbout").click(function(){ClosePopup("About","AboutBackground","slow");});$("#AboutBackground").click(function(){ClosePopup("About","AboutBackground","slow");});$("#SentOkBackground").click(function(){ClosePopup("SentOk","SentOkBackground","slow");});$("#CloseSentOK").click(function(){ClosePopup("SentOk","SentOkBackground","slow");});$(document).keypress(function(e){if(e.keyCode==27){ClosePopup("OrderOnlineForm","backgroundPopup","slow");}});$("#PopupMenu").fadeIn(1);$("#PopupMenu").fadeOut(1);$(function(){$(".dlPCType").find("a").click(function(){$(this).parent().find("input").trigger("click");if($(this).hasClass("aPCTypeon")){$(this).removeClass("aPCTypeon");}else{$(this).addClass("aPCTypeon");}
return false;})});$(function(){$(".FormFontItem").find("a").click(function(){$(this).parent().find("input").trigger("click");if($(this).hasClass("aFormFontSelectedon")){$(this).removeClass("aFormFontSelectedon");}else{$(this).addClass("aFormFontSelectedon");}
return false;})});$(function(){$(".ApproveTermsofUseTbl").find("a").click(function(){$(this).parent().find("input").trigger("click");if($(this).hasClass("aTermsofUseSelectedon")){$(this).removeClass("aTermsofUseSelectedon");}else{$(this).addClass("aTermsofUseSelectedon");}
return false;})});$(function(){$(".divPackagesSelctor").find("a").click(function(){if($(this).parent().find("input").is(':checked')){}
else{$(this).parent().parent().find("a").each(function(){if($(this).hasClass("aWeightson")){$(this).removeClass("aWeightson");}});$(this).parent().parent().find("input").each(function(){$(this).attr('checked',false);});}
$(this).parent().find("input").trigger("click");if($(this).hasClass("aWeightson")){$(this).removeClass("aWeightson");}else{$(this).addClass("aWeightson");}
calcFontsPrice();return false;})});$(function(){$(".weightSelector").find("a").click(function(){if($(this).parent().find("input").is(':checked')){}
else{$(this).parent().parent().parent().find("a").each(function(){if($(this).hasClass("aWeighton")){$(this).removeClass("aWeighton");}});$(this).parent().parent().parent().find("input").each(function(){$(this).attr('checked',false);});}
$(this).parent().find("input").trigger("click");if($(this).hasClass("aWeighton")){$(this).removeClass("aWeighton");}else{$(this).addClass("aWeighton");}
calcFontsPrice();return false;})});$(function(){$(".dlNumOfPayments").find("a").click(function(){if($(this).hasClass("aNumOfPaymentson")){return false;}
if($(this).hasClass("aNumOfPaymentsoff")){ClearRadioButtenListSelection("dlNumOfPayments");$("a.aNumOfPaymentson").removeClass("aNumOfPaymentson");$(this).parent().find("input").trigger("click");if($(this).hasClass("aNumOfPaymentson")){$(this).removeClass("aNumOfPaymentson");}else{$(this).addClass("aNumOfPaymentson");}
return false;}})});$(function(){$(".dlPCType").find("a").each(function(){if($(this).parent().find("input")[0].checked){$(this).addClass("aPCTypeon");}})
$(".dlNumOfPayments").find("a").each(function(){if($(this).parent().find("input")[0].checked){$(this).addClass("aNumOfPaymentson");}})
$(".weightDropDown").find("a").each(function(){if($(this).parent().find("input")[0].checked){$(this).addClass("aWeighton");}})
$(".divTermsofUse").find("a").each(function(){if($(this).parent().find("input")[0].checked){$(this).addClass("aTermsofUseSelectedon");}})});$(function(){if(jQuery.browser.msie&jQuery.browser.version<8.0){$(".OrderMe").css('margin-top',-10);}
else if(jQuery.browser.safari){$(".OrderMe").css('margin-top',-35);$(".OrderMe").css('margin-left',35);}
else if(jQuery.browser.opera)
{positionOpera();}
else{$(".OrderMe").css('margin-top',-35);}});registerDropDowns();getFormXML(function(){calcFontsPrice();});$(".FieldValueNumOfComp").each(function(){$(this).change(calcFontsPrice);});});function positionOpera()
{$(".OrderMe").css('margin-top',-35);$(".OrderMe").css('right',540+((window.innerWidth-915)/2));window.setTimeout(function(){positionOpera();},1000);}
function ClearRadioButtenListSelection(divName){var radio=document.getElementById(divName).getElementsByTagName("input");for(i=0;i<radio.length;i++){if(radio[i].type=="radio")
radio[i].checked=false;}}
function registerDropDowns()
{numOfDropDowns=$(document).find("div").filter(".DropDownLine").length;DropDowns=new Array(numOfDropDowns);$(document).find("div").filter(".DropDownLine").each(function(index){var dropDownID="";var menuController="";$(this).find("span").filter(".spnNumOfWeights").each(function(){menuController=$(this);});$(this).find("div").filter(".weightDropDown").each(function(){dropDownID=$(this).attr('id');$(this).hover(function(){},function(){ClosePopup(dropDownID,"",100);openDropDown="";});});DropDowns[index]=dropDownID;$(this).find("span").filter(".spnNumOfWeights").click(function(){if(openDropDown==dropDownID){ClosePopup(dropDownID,"");openDropDown="";}
else{for(var i=0;i<numOfDropDowns;i++){if(DropDowns[i]!=dropDownID){ClosePopup(DropDowns[i],"");}}
if(jQuery.browser.msie&jQuery.browser.version<8.0){$("#"+dropDownID).css('left',menuController.position().left);}
else{$("#"+dropDownID).css('left',menuController.position().left);}
OpenPopup(dropDownID,"",150);openDropDown=dropDownID;}});});}
function calcFontsPrice()
{var totalPrice=0;var selectedHTML="";var numOfComputers=1;$(".FieldValueNumOfComp").each(function(){numOfComputers=$(this).val();});for(var i=0;i<numOfDropDowns;i++)
{var dropDownList=$("#"+DropDowns[i]);var fontID=dropDownList.find("input")[0].value;var fontNode=$(formXML).find("//fonts/font[fontID='"+fontID+"\']");var AvailableWeights;fontNode.find("weights").each(function()
{AvailableWeights=$(this).find("weight").length;});var fontPrice=0;var packPrice=0;var halfPackPrice=0;var hasHalf=false;var fontName="";var dottedFontPrice=0;var dottedPackPrice=0;fontNode.each(function(){fontPrice=parseInt($(this).attr('fontPrice'));packPrice=$(this).attr('PackPrice');halfPackPrice=$(this).attr('halfPackPrice');fontName=$(this).attr('title');dottedFontPrice=$(this).attr('dottedFontPrice');dottedPackPrice=$(this).attr('DottedPackPrice');});selectedHTML+="[b]"+fontName+"[/b] - ";if(packPrice=="")
{packPrice=fontPrice*AvailableWeights;}
else
{packPrice=parseInt(packPrice);}
if(dottedPackPrice=="")
{dottedPackPrice=packPrice;}
else
{dottedPackPrice=parseInt(dottedPackPrice);}
if(dottedFontPrice==""||dottedFontPrice==null)
{dottedFontPrice=fontPrice;}
else
{dottedFontPrice=parseInt(dottedFontPrice);}
if(halfPackPrice=="")
{halfPackPrice=fontPrice*Math.floor(AvailableWeights/2);hasHalf=false;}
else
{halfPackPrice=parseInt(halfPackPrice);hasHalf=true;}
var regulrDottedDiff=dottedFontPrice-fontPrice;var allWeightsSelected=dropDownList.find("div").filter(".allWeights").find("input")[0].checked;var allDottedWeightsSelected=dropDownList.find("div").filter(".allDottedWeights").find("input")[0];if(allDottedWeightsSelected!=null)
{allDottedWeightsSelected=allDottedWeightsSelected.checked;}
else
{allDottedWeightsSelected=false;}
if(allDottedWeightsSelected)
{totalPrice+=dottedPackPrice;selectedHTML+="חבילה מנוקדת ("+dottedPackPrice+")";dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חבילה מנוקדת</span>");}
else if(allWeightsSelected)
{var selectedDottedWeights=0;var dottedSelectedHTML="";dropDownList.find("div").filter(".weightSelector").find("input").each(function(){if($(this)[0].checked)
{if($(this).parent().attr('isDotted')=="true")
{selectedDottedWeights++;if(selectedDottedWeights>1)
{dottedSelectedHTML+=", ";}
else
{dottedSelectedHTML+=" +  תוספת ניקוד: ";}
dottedSelectedHTML+=$(this).parent().attr('weightName');}}});if(selectedDottedWeights==AvailableWeights)
{totalPrice+=dottedPackPrice;selectedHTML+="חבילה מנוקדת ("+dottedPackPrice+")";dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חבילה מנוקדת</span>");}
else
{totalPrice+=packPrice+(selectedDottedWeights*regulrDottedDiff);selectedHTML+="חבילה ("+packPrice+")"+dottedSelectedHTML;if(selectedDottedWeights==0)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חבילה</span>");}
else
{var displayText="חבילה";if(selectedDottedWeights==1)
{displayText+=" + משקל מנוקד";}
else
{displayText+=" + "+selectedDottedWeights+" מנוקדים";}
dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">"+displayText+"</span>");selectedHTML+=" ("+(selectedDottedWeights*regulrDottedDiff)+")";}}}
else
{var SelectedWeights=0;var regularSelectedHTML="";dropDownList.find("div").filter(".weightSelector").find("input").each(function(){if($(this)[0].checked){SelectedWeights++;if(SelectedWeights>1)
{regularSelectedHTML+=", ";}
regularSelectedHTML+=$(this).parent().attr('weightName');}});var selectedDottedWeights=0;var dottedSelectedHTML="";dropDownList.find("div").filter(".weightSelector").find("input").each(function(){if($(this)[0].checked){if($(this).parent().attr('isDotted')=="true"){selectedDottedWeights++;if(selectedDottedWeights>1){dottedSelectedHTML+=", ";}
else{dottedSelectedHTML+=" + תוספת ניקוד: ";}
dottedSelectedHTML+=$(this).parent().attr('weightName');}}});var regularSelected=SelectedWeights-selectedDottedWeights;if(selectedDottedWeights==AvailableWeights)
{totalPrice+=dottedPackPrice;selectedHTML+="חבילה מנוקדת ("+dottedPackPrice+")";dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חבילה מנוקדת</span>");}
else if(SelectedWeights==AvailableWeights)
{totalPrice+=packPrice+(selectedDottedWeights*regulrDottedDiff);selectedHTML+="חבילה ("+packPrice+")";if(selectedDottedWeights==0)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חבילה</span>");}
else
{var displayText="חבילה";if(selectedDottedWeights==1)
{displayText+=" + משקל מנוקד";}
else
{displayText+=" + "+selectedDottedWeights+" מנוקדים";}
dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">"+displayText+"</span>");selectedHTML+=dottedSelectedHTML+" ("+(selectedDottedWeights*regulrDottedDiff)+")";}}
else if(hasHalf&&SelectedWeights==Math.floor(AvailableWeights/2))
{totalPrice+=halfPackPrice+(selectedDottedWeights*regulrDottedDiff);selectedHTML+="חצי חבילה - "+regularSelectedHTML+" ("+packPrice+")";if(selectedDottedWeights==0)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">חצי חבילה</span>");}
else
{var displayText="חצי חבילה";if(selectedDottedWeights==1)
{displayText+=" + משקל מנוקד";}
else
{displayText+=" + "+selectedDottedWeights+" מנוקדים";}
dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">"+displayText+"</span>");selectedHTML+=dottedSelectedHTML+" ("+(selectedDottedWeights*regulrDottedDiff)+")";}}
else
{if(SelectedWeights==0)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("בחירת משקלים");}
else if(SelectedWeights==1&&selectedDottedWeights==1)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">נבחר משקל מנוקד</span>");}
else if(SelectedWeights==1)
{dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">נבחר משקל אחד</span>");}
else
{var displayText="";var regularWeights=SelectedWeights-selectedDottedWeights;if(regularWeights==1)
{if(selectedDottedWeights==0)
{displayText+="נבחר ";}
displayText+="משקל";}
else if(regularWeights>0)
{if(selectedDottedWeights==0)
{displayText+="נבחרו ";}
displayText+=regularWeights+" משקלים";}
if(selectedDottedWeights==1)
{if(regularWeights==0){displayText+="נבחר";}
else{displayText+=" +";}
displayText+=" משקל מנוקד";}
else if(selectedDottedWeights>0)
{if(regularWeights==0){displayText+="נבחרו ";}
else{displayText+=" + ";}
displayText+=selectedDottedWeights+" מנוקדים";}
dropDownList.parent().find("span").filter(".lblNumOfWeights").html("<span class=\"NumWeightsSelected\">"+displayText+"</span>");}
totalPrice+=(SelectedWeights*fontPrice)+(selectedDottedWeights*regulrDottedDiff);selectedHTML+=regularSelectedHTML+" ("+SelectedWeights*fontPrice+")";if(selectedDottedWeights!=0)
{selectedHTML+=dottedSelectedHTML+" ("+(selectedDottedWeights*regulrDottedDiff)+")";}}}
selectedHTML+="[br /]";}
var compExtra=Math.floor((numOfComputers-1)/5)*(totalPrice*0.5);totalPrice+=compExtra;selectedHTML+="[br /]תוספת מספר מחשבים - ₪"+compExtra+"[br /][br /]";selectedHTML+="[b]סה\"כ - ₪"+totalPrice+"[/b]";$(document).find("input").filter(".hfSelectedWeights").each(function(){$(this).val(selectedHTML);});$("#PaymentTotal").html("₪"+totalPrice);}