﻿function CreateFlash(container,id,src,width,height,extraHtml){//handles any arguments beside these
    var objStr="",embedStr="",parSplit;
    for (i=6; i<CreateFlash.arguments.length; i++){
        parSplit=CreateFlash.arguments[i].split("=");
        objStr+="<param name='"+parSplit[0]+"' value='"+parSplit[1]+"' />"
        embedStr+=" "+parSplit[0]+"='"+parSplit[1]+"' "
    }
    var el=document.getElementById(container);
    el.innerHTML="\
    <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' \
        width='"+width+"' height='"+height+"' id='"+id+"'>\
	    <param name='movie' value='"+src+"' />\
	    "+objStr+" \
	    <embed type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' \
	    src='"+src+"' width='"+width+"' height='"+height+"'\
	    name='"+id+"' "+embedStr+" />\
    </object>\
     "+ (extraHtml?extraHtml:"")+"\
    ";
}

function CreatePromoFlash(container){
	var el=document.getElementById(container);
	el.innerHTML+="\
	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='500' height='500' id='newBottle' align='middle'>\
		<param name='allowScriptAccess' value='always' />\
		<param name='movie' value='swf/newBottle.swf' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='swf/newBottle.swf' menu='false' quality='high' wmode='transparent' width='500' height='500' name='newBottle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\
	</object>";
}

function openProductForm(){
    DOM.Get("orderForm").style.display="block";
}

function sendProductForm(siteUrl){

    document.getElementById("resultOK").style.display="none";
    document.getElementById("resultFailed").style.display="none";

    if(DOM.Get("nameField").value=="" ||DOM.Get("addressField").value=="" ||DOM.Get("phoneField").value==""){
        alert("נא למלא את כל הפרטים");
        return;
    }

    var xReq=Browser.XML.HTTP();


    var postData="pName="+encodeURI(DOM.Get("nameField").value).replace("&","")+"\
    &pAddress="+encodeURI(DOM.Get("addressField").value).replace("&","")+"\
    &pPhone="+encodeURI(DOM.Get("phoneField").value).replace("&","")+"\
    &product="+encodeURI(DOM.Get("productNameField").value).replace("&","")+" - "+encodeURI(DOM.Get("productVersionField").value).replace("&","")

    xReq.open("POST",siteUrl+"productPost.asp",true);

    xReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    xReq.onreadystatechange=function(){
        if(xReq.readyState==4){
            if(xReq.responseText=="OK") {document.getElementById("resultOK").style.display="block";
				javascript:urchinTracker('/product/detailssent')
            }
            else document.getElementById("resultFailed").style.display="block";
        }
    };


    xReq.send(postData);

}
// called from the main flash
function openLightbox(){
	ContactLightbox.Open();
}

function urchinTracker(trackId) {
    //simulate urchin tracker with the new tracker...
    _gaq.push(['_trackPageview', trackId]);
}

var ContactLightbox={
    Lightbox:null,
	wrapperId:"",
    Init:function(){
		ContactLightbox.wrapperId = "ContactLightboxWrap";
		ContactLightbox.Lightbox=new Lightbox($(ContactLightbox.wrapperId));
		if($("btContactLightboxClose"))$("btContactLightboxClose").addEvent("click",ContactLightbox.Close);
    },

    Open:function(){
	$(ContactLightbox.wrapperId).show();
	ContactLightbox.Lightbox.show();
	urchinTracker('/outbound/easy/Main_banner_open');
    },
    Close:function(){
	$(ContactLightbox.wrapperId).hide();
	ContactLightbox.Lightbox.hide();
	urchinTracker('/outbound/easy/Main_banner_close');
    }

};

var Site={
	openLivePerson:function(){
		lpMakeCallWithSize('liveperson/CallRequest.asp', 'Easy', '1','http://www.meyeden.co.il/service.asp',0,501,309);
	}
}

function validateLightbox(oForm){
	var err = 0;
	if(oForm.fullname.value=="" && err==0){
		alert("נא להזין שם");
		oForm.fullname.focus();
		err++;
	}

	if(oForm.phone.value=="" && err==0 ){
		alert("נא להזין טלפון");
		oForm.phone.focus();
		err++;
	}
	if (err==0){
		$("lightboxMsg").innerHTML = "שולח... נא להמתין";
		$("contactForm").hide();

		return true;
	}else{
		return false;
	}
}

function flashSender(name, email, phone, phone2)
{
    urchinTracker('/easy/virtual/thankyou');
	location.href='flashSender.asp?name='+name+'&email='+email+'&phone='+phone+'&phone2='+phone2+'&ref='+ref;
}
