function activateLoadingDiv(){ 
document.getElementById("ajax_loading").style.top =  document.body.scrollTop + 5;
document.getElementById("ajax_loading").style.display = "block";
}

function removeLoadingDiv() { document.getElementById("ajax_loading").style.display = "none"; }

function showFlash(divID,data){
var d = document.getElementById(divID);
d.innerHTML=data; 
}

function showBan(divID, width, height, src){
var d = document.getElementById(divID);
d.innerHTML='<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0  WIDTH='+width+' HEIGHT='+height+'><PARAM NAME=wmode VALUE=transparent><param name=allowScriptAccess value=sameDomain><param name=allowFullScreen value=true><PARAM NAME=movie VALUE="'+src+'"><PARAM NAME=quality VALUE=high><param name=allowScriptAccess value=allowScriptAccess><param name=bgcolor value=""><EMBED src="'+src+'" quality="high" wmode="transparent" WIDTH='+width+' HEIGHT='+height+' bgcolor="" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>';
}

var siteCache=new Array();
var scriptStr="";

function checkBrowser(){
var navFamily = navigator.userAgent.toLowerCase();
	if (navFamily.indexOf('msie')!=-1) {
		var ver = parseFloat( navFamily.substring(navFamily.indexOf('msie')+5,navFamily.length) );
		scriptStr='SCRIPT';
		navFamily = 'IE6';
	} else if (navFamily.indexOf('gecko')!=-1) {
		var ver = parseFloat( navFamily.substring(navFamily.indexOf('gecko')+6,	navFamily.length) );
		scriptStr='script';
		navFamily = 'Gecko';
	} else {
		scriptStr='script'; navFamily = 'Gecko';
	}
return navFamily;
}
var myBrowser = checkBrowser();


function ajaxUrl(url,aid,cashe_stat,showLoading){
var siteHTTP;
if(showLoading==1) activateLoadingDiv();
if (siteCache[url]!=null) {
                    document.getElementById(aid).style.display="block"; 
					document.getElementById(aid).innerHTML = siteCache[url]; 
					removeLoadingDiv();  
					return;
}

if (window.XMLHttpRequest){
siteHTTP=new XMLHttpRequest();
siteHTTP.onreadystatechange=state_Change;
siteHTTP.open("POST",url,true);
siteHTTP.send(null);
} else if (window.ActiveXObject){
siteHTTP=new ActiveXObject("Microsoft.XMLHTTP");
if (siteHTTP){
siteHTTP.onreadystatechange=state_Change;
siteHTTP.open("POST",url,true);
siteHTTP.send();
}
}

function state_Change(){
if (siteHTTP.readyState==4){ 
		if (siteHTTP.status==200){
		document.getElementById(aid).style.display="block"; 
		document.getElementById(aid).innerHTML = siteHTTP.responseText; 
		if(cashe_stat==1) siteCache[url]=siteHTTP.responseText; 
		removeLoadingDiv();
		evalObjJavascript(aid); 
		}
}
}
}

function MyexecScript(txt){
if (myBrowser == 'IE6'){
try{execScript(txt,"JavaScript");}
catch(err){}
} else {			
var head = document.getElementsByTagName('head').item(0);
script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML=txt;
head.appendChild(script);
}
return false;
}


function evalObjJavascript(oname){
tobj=document.getElementById(oname);
if(typeof tobj == 'object'){
	var TmpHtml=tobj.innerHTML;
	var oEval=TmpHtml.search('<'+scriptStr+'>');
	var Max=5;
		for(i=0; i<Max && oEval>=0 ;i++){
		var tmp=TmpHtml.substring(oEval,TmpHtml.length).search('</'+scriptStr+'>');
		sEval=TmpHtml.substring(oEval+8,oEval+tmp);
		MyexecScript(sEval);
		TmpHtml=TmpHtml.substring(oEval+tmp+9,TmpHtml.length);
		oEval=TmpHtml.search('<'+scriptStr+'>');
		}
	}
return false;
}

// forum functions //
function open_forumAdmin(faid){
window.open("/pop/forumAdmin.php?id="+faid,"adminPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}

function forumPages(fid,p){
location.href = "/forum.php?fid="+fid+"&p="+p;
}

function addForumM(fid,faid){
window.open("/pop/addForumM.php?fid="+fid+"&faid="+faid,"messagePop","top=10,left=10,width=450,height=510,toolbar=no,location=no");
}

function forumBody(id,isRoot){
if(document.getElementById("fm_"+id).style.display=="block"){ document.getElementById("fm_"+id).style.display="none"; document.getElementById("fRow_"+id).className="forum-"+isRoot; }
else { res = ajaxUrl("/ajax/forumBody.php?id="+id,"fm_"+id,1,1); document.getElementById("fRow_"+id).className="forum-open"; }
}

// sheelon functions //
var sheelonWindow = null;
function openSheelon(sheelonId){
sheelonWindow = window.open("/pop/sheelon.php?id="+sheelonId,"sheelonPop","top=10,left=10,width=485,height=400,toolbar=no,location=no");
}

// clinic functions
// right side clinic search
function search_clinic_buxa(){
//if(document.getElementById("search_clinic_area_id").value==""){ document.getElementById("search_clinic_area_id").focus(); return;}
if(document.getElementById("search_clinic_category_id").value==""){ document.getElementById("search_clinic_category_id").focus(); return;}
location.href="/clinics.php?cid="+document.getElementById("search_clinic_category_id").value+"&area="+document.getElementById("search_clinic_area_id").value;
}

function clinic_contact_focus(){
//document.getElementById("contact_us_btn").style.display="none"; 
document.getElementById("clinicWorld").innerHTML="";
if(clinic_tab_selected>=0) document.getElementById("clinic_tab_"+clinic_tab_selected).className="clinic_tab_off"; 
clinic_tab_selected=-1;
document.getElementById("fullname").focus(); 
}

function open_clinic_hours(clinic_id){
window.open("/pop/clinicHours.php?id="+clinic_id,"hoursPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}

function show_clinic_phone(clinic_id, click_type){
ajaxUrl("/ajax/clinic_phone.php?clinic_id="+clinic_id+"&click_type="+click_type,"clinic_phone_world",1,1);
}


function openCoupon(clinic_id){
window.open("/pop/coupon.php?id="+clinic_id,"couponPop","top=10,left=10,width=495,height=380,toolbar=no,location=no");
}

function clinicSuggest(clinic_id){
window.open("/pop/clinicSuggest.php?id="+clinic_id,"suggestPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}

function openHavayaPop(){
window.open("/pop/sendHavaya.php","havayaPop","top=10,left=10,width=435,height=620,toolbar=no,location=no");
}

function openTipPop(){
window.open("/pop/sendTip.php","tipPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}

function openSend2friend(){
window.open("/pop/send2friend.php?pageURL="+top.document.location,"sendPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}


function clinicEsteticaDetails(clinic_id){
var iframe_div = document.getElementById('ciframe_'+clinic_id);
var image_details = document.getElementById('img_details_'+clinic_id);
if(iframe_div.style.display == 'none'){
image_details.src="http://www.estetica.co.il/u/icons/g/details_down.gif";
if(iframe_div.innerHTML=="")iframe_div.innerHTML="<iframe width=595 height=480 scrolling=No src='/inc/clinic_details.php?id="+clinic_id+"' frameborder=0 style='margin:0px; border:1px solid #f0f0f0;'></iframe>";
$(iframe_div).slideDown(1000);
//iframe_div.style.display = 'block';
}
else{
image_details.src="http://www.estetica.co.il/u/icons/g/details.gif";   
//iframe_div.style.display = 'none';
$(iframe_div).slideUp(500);
}
}

function clinicDetails(clinic_id){
var iframe_div = document.getElementById('ciframe_'+clinic_id);
var image_details = document.getElementById('img_details_'+clinic_id);
if(iframe_div.style.display == 'none'){
image_details.src="http://www.estetica.co.il/u/icons/g/details_down.gif";
if(iframe_div.innerHTML=="")iframe_div.innerHTML="<iframe width=736 height=480 scrolling=No src='/minisite/details.php?id="+clinic_id+"' frameborder=0 style='margin:0px; border:1px solid #D84492;'></iframe>";
$(iframe_div).slideDown(1000);
//iframe_div.style.display = 'block';
}
else{
image_details.src="http://www.estetica.co.il/u/icons/g/details.gif";   
//iframe_div.style.display = 'none';
$(iframe_div).slideUp(500);
}
}

// before after galleries
function switch_ba_gallery(object_type, object_id, gallery_id){
ajaxUrl("/ajax/ba_gallery.php?object_type="+object_type+"&object_id="+object_id+"&gallery_id="+gallery_id,"before_after_world",0,1);
}

// pink menus
function showMenu(menu_id){ document.getElementById("menu_"+menu_id).style.display="block"; }
function hideMenu(menu_id){ document.getElementById("menu_"+menu_id).style.display="none"; }

function email_validate(email_address) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(email_address) == false) return 0; else return 1; 
}

var HPscrollTimeout=null;
var HPscrollDirection;
var HPscrollPos;
var HPscrollDivName;

function HPscrollDiv(){
HPscrollPos=document.getElementById(HPscrollDivName).scrollTop;
document.getElementById(HPscrollDivName).scrollTop=HPscrollPos+(HPscrollDirection*2);
HPscrollTimeout=setTimeout(HPscrollDiv,10);
}

function HPstartScrollDiv(d,scroll_div){
HPscrollDivName = scroll_div;
HPscrollDirection=d;
if (HPscrollTimeout!=null) clearTimeout(HPscrollTimeout);
HPscrollTimeout=setTimeout(HPscrollDiv,0);
}

function HPendScrollDiv(){ if (HPscrollTimeout!=null) clearTimeout(HPscrollTimeout); }


// product function 
function openProductCoupon(product_id){
window.open("/pop/coupon_product.php?id="+product_id,"couponPop","top=10,left=10,width=495,height=380,toolbar=no,location=no");
}


// blogs functions //
function open_blog_admin(aid){
window.open("/pop/blog-admin.php?id="+aid,"adminPop","top=10,left=10,width=435,height=420,toolbar=no,location=no");
}

// resize div functions 
var ResizeObject, ResizeObjectHeight, ResizeHeight, ResizeSpeed=5;

function closeDiv(){
ResizeHeight-=parseInt(ResizeHeight/ResizeObjectHeight*10)+5;
if(ResizeHeight>=0)ResizeObject.style.height=ResizeHeight+1;
if(ResizeHeight>0)setTimeout("closeDiv();",ResizeSpeed);
else ResizeObject.style.display="none";
}

function openDiv(){
ResizeHeight+=parseInt(ResizeHeight/ResizeObjectHeight*10)+5;
ResizeObject.style.height=ResizeHeight+1;
if(ResizeHeight<=ResizeObjectHeight)setTimeout("openDiv();",ResizeSpeed);
}

function ToggleResize(divID,h){
ResizeObject=document.getElementById(divID); 
ResizeObject.style.overflow="hidden";
ResizeObjectHeight=h;
if(ResizeObject.style.display=="none"){ ResizeObject.style.display="block";  ResizeHeight=0;   openDiv(); }
else { ResizeHeight=h; closeDiv(); }
}


function Check_Boxs_Comma(form_name, checkbox_name){
var checkboxObj, c, formObj = document.getElementById(form_name), clinics_ids;
clinics_ids="0";
for(c=0 ; c<formObj.elements.length ;c++){
checkboxObj=formObj.elements[c];
if(checkboxObj.checked && checkboxObj.id==checkbox_name){ clinics_ids+=","+checkboxObj.value; }
}
return(clinics_ids);
}



function clinics_multiple_sent(){
var iframe_object = document.getElementById("ciframe_multiple");
if(iframe_object.style.display=="block") return;
document.getElementById("multiple_empty").style.display="none"; 

checkboxes_str = Check_Boxs_Comma("multipleForm","clinic_check_box[]");
if(checkboxes_str=="0"){ document.getElementById("multiple_empty").style.display="block";  return; } 
  //              document.getElementById("multiple_close").style.display="none"; 
//                iframe_object.style.display="none"; iframe_object.src="/minisite/loading.html"; return; 

iframe_object.style.display="block";
document.getElementById("multiple_close").style.display="block"; 
document.getElementById("multipleForm").method="POST";
document.getElementById("multipleForm").action="/inc/clinic_multiple_send.php";
document.getElementById("multipleForm").submit();

}

function closeMultiple(){
document.getElementById("multiple_empty").style.display="none"; 
document.getElementById("multiple_close").style.display="none";
document.getElementById("ciframe_multiple").style.display="none";
}



var winWidth,winHeight;
function detectBrowserWH(){ 
if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") { winWidth = window.innerWidth; winHeight = window.innerHeight; }
	if (navigator.appName.indexOf("Microsoft")!=-1) { winWidth = document.body.offsetWidth-20; winHeight = document.body.offsetHeight-20; }
}	
}

function topShade(url,w,h){ 
ToggleShade(1); 
detectBrowserWH(); 
var x="<div align=right><img src='http://www.estetica.co.il/u/icons/g/close_btn.gif' class=hand onclick='ToggleShade(0);'></div><iframe id='Inner_Shade_Iframe' name='Inner_Shade_Iframe' src='"+url+"' style='width:"+w+"px; height:"+h+"px; margin:0px;' frameborder=0 scrolling=No></iframe>";
document.getElementById('shade_iframe').innerHTML=x; 
document.getElementById('shade_iframe').style.top=winHeight/2-h/2;
document.getElementById('shade_iframe').style.left=winWidth/2-w/2;
}

function ToggleShade(ac){
if(ac==0) { document.getElementById('shade_screen').style.display='none'; document.getElementById('shade_iframe').style.display='none';}
if(ac==1) { document.getElementById('shade_screen').style.display='block'; document.getElementById('shade_iframe').style.display='block';}
}


function isNumeric(str){
var numbers = "0123456789";
if(str.length==0) return false;
for (var i=0; i < str.length; i++){
        var ch = str.substring(i, i+1);
		if(numbers.indexOf(ch)<0) return false;
	}
return true;
}


function isValidPhone(str) {
if(isNumeric(str)==true && str.length>=9) return true; 
else return false; 
}

