// JavaScript Document
$().ready(function(){
	setInterval("check_hash()", 300);
	 });

function var_dump(obj) {
	if(typeof obj == "object") {
		return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
	} else {
		return "Type: "+typeof(obj)+"\nValue: "+obj;
	}
}


var current_hash = null;

function check_hash() {
    if ( window.location.hash != current_hash ) {
		
        current_hash = window.location.hash;
		//alert(var_dump(current_hash));
		var t2=new Array;
		t2=current_hash.substr( 1,  current_hash.length);
		t3=t2.split('#');
		//alert(var_dump(t3));
		//alert(t3.length);
		//alert(t3[0]);
		//alert(t3[1]);
		if (t3.length == 2){
			if (t3[0]== "PressDetails")
			ViewDetails("pressdetails.php",t3[1]);
			else
			ViewDetails("gallery.php",t3[1]);
			}else {
		var t= current_hash.substr( 1,  current_hash.length);
		var f;
		if ( t !=""){
		if ( t == "AntiAgeing"){
		f=12;
		View(f,t );
		}
		if ( t == "SkinDisorders"){
		f=14;
		View(f,t );
		}
		if ( t == "LaserClinic"){
		f=16;
		View(f,t );
		}
		if ( t == "Dental"){
		f=15;
		View(f,t );
		}
		if ( t == "HairClinic"){
		f=18;
		View(f,t );
		}
		if ( t == "PressReleases")
		ViewContent("press_releases.php",t);
		if ( t == "Promotion")
		ViewContent("promotion.php",t);
		if ( t == "SalalahBranch")
		ViewContent("salalah.php",t);
		if ( t == "Testimonials")
		ViewContent("testimonials.php",t);
		if ( t == "OurDoctors")
		ViewContent("ourdoctors.php",t);
		if ( t == "ContactUs")
		ViewContent("contactus.php",t);
		if ( t == "BookAppointment")
		ViewContent("bookappt.php",t);
		if ( t == "RequestCall")
		ViewContent("requestcall.php",t);
		if ( t == "KeepInformed")
		ViewContent("keepinformed.php",t);
		if ( t == "LocationMap")
		ViewContent("locationmap.php",t);
		if ( t == "SiteMap")
		ViewContent("sitemap.php",t);
		if ( t == "Home")
		show_cats();
		
		if ((t != "AntiAgeing") && (t != "SkinDisorders") && (t != "LaserClinic") && (t != "Dental") && (t != "HairClinic") && (t !="Home") && ( t!= "PressReleases") && ( t != "Testimonials") && ( t != "OurDoctors")&& ( t != "ContactUs") && ( t != "BookAppointment") && ( t != "RequestCall") && ( t != "KeepInformed") && ( t != "LocationMap") && ( t != "SiteMap") && ( t != "Promotion") && ( t != "SalalahBranch"))
		VeiwData("en_headings",t);
		} else show_cats();
		}// lenght2
		}
	
}

function ShowDiv(e){
	$('#Submain'+e).show();

	}
function ShowGall(){
	$('#Gall').show();

	}
function HideGall(){
	$('#Gall').hide();

	}
function HideAll(){
	$('#Aboutus').hide();
	$('#Services').hide();
	$('#Contactus').hide();
	
	}
function HideAllDiv(){
	var n;
	for(n=0;n<5;n++)
	$('#Submain'+n).hide();
	}

function HideDiv(e){
	$('#Submain'+e).hide();

	}
function HideDiv1(){
	$('#Submain').hide();

	}
function ShowMain(e){
	$('#'+e).show();
	}
function HideMain(e){
	$('#'+e).hide();
	}
//------------------------------------ View For 5 Main Cats -------------------------
function View(id , title){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
$('#cats').hide();
$('#Ajax').show();
$('#Ajax').html('<div align="center"><img src="images/ajax-loader.gif"  /></div>');
//window.location.hash = "#"+title;
var str= title;
var str2=unescape(str);
var str3=str2.replace("&amp;","&");
window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');$('#Show').hide();
$("#Show").load('show_data.php',{id: id  },function(){
	window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');
	$('#Ajax').hide();
	$('#Show').slideDown(1000);});
  };
//------------------------------------ Change Title -------------------------  
  function ChTitle()
  {
	  setTimeout("ChangeTitle()", 200);
  }
  function ChangeTitle()
  {
	  var current_hash = window.location.hash;
	  var t= current_hash.substr( 1,  current_hash.length);
	  t33=t.split('#');
	  	  var str= t33[0];
		var str2=unescape(str);
		var str3=str2.replace("&amp;","&");
		window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');
  }
  
//------------------------------------ ViewContent For Cats & Static Pages -------------------------
function ViewContent(PageId,Title){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
HideAll();
$('#cats').hide();
$('#Ajax').show();
$('#Ajax').html('<div align="center"><img src="images/ajax-loader.gif"  /></div>');
//window.document.title=" ";
//window.location.hash = "#"+Title;
var str= Title;
var str2=unescape(str);
var str3=str2.replace("&amp;","&");
window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');$('#Show').hide();
$("#Show").load(PageId,function(){ window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');
$('#Ajax').hide();$('#Show').slideDown(1000);});
};
//------------------------------------ ViewData For Single Content -------------------------
function VeiwData(table , title){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
HideAll();
$('#cats').hide();
$('#Ajax').show();
$('#Ajax').html('<div align="center"><img src="images/ajax-loader.gif"  /></div>');
//window.document.title=" ";
//window.location.hash = "#"+title;
var str= title;
var str2=unescape(str);
var str3=str2.replace("&amp;","&");
window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');$('#Show').hide();
$("#Show").load('retrive_data.php',{table : table ,title: title  },function(){window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');$('#Ajax').hide();$('#Show').slideDown(1000);});
  };
  
//------------------------------------ ViewDetails For GAllery & PressDetails -------------------------  
function ViewDetails(PageId,Id){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
HideAll();
$('#cats').hide();
$('#Ajax').show();
$('#Ajax').html('<div align="center"><img src="images/ajax-loader.gif"  /></div>');
var str2=unescape(t3[0]);
var str3=str2.replace("&amp;","&");
window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');

$('#Show').hide();
$("#Show").load(PageId,{id : Id},function(){
	ChTitle();
	window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');
	$('#Ajax').hide();
	$('#Show').slideDown(1000);
	
	});
	
	window.document.title= "Emirates  Medical Center - "+ str3.replace(/\+/g,' ');
};
//------------------------------------------------------------------------------------------------------------

function show_cats(){
	  $('#Show').hide();
	  $('#Ajax').hide();
	  $('#cats').slideDown(1000);
	  window.location.hash = "#Home";
	  window.document.title= "EMC - Oman - Skin Health - Dermatology - Botox - Fillers - Laser Treatments - Crystal Peeling";
	  }
//-------------------------------------------------------------

function SubmitMessage(){
	   var Pass =  validateForm_contactus();
	   if (Pass == true){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
//$('#data').html('<div style="text-align:center"><img src="images/ajax-loader.gif"  /><\/div>');
var branch=document.getElementById("branch").value;
var to=document.getElementById("to").value;
var fname=document.getElementById("fname").value;
var subject=document.getElementById("subject").value;
var gsm=document.getElementById("gsm").value;
var email=document.getElementById("email").value;
var message=document.getElementById("message").value;
$("#Show").load('contactus.php',{fname: fname,subject: subject ,email: email, gsm : gsm,message: message,to : to,branch : branch,send: "true"},function(){$('#Show').hide();$('#Show').slideDown(1000);});
  } else return Pass;
  };
 //-------------------------------------------------------------

function SubmitMailinglist(){
	   var Pass =  validateForm_keepinformed();
	   if (Pass == true){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
//$('#data').html('<div style="text-align:center"><img src="images/ajax-loader.gif"  /><\/div>');
var fname=document.getElementById("fname").value;
var gsm=document.getElementById("gsm").value;
var email=document.getElementById("email").value;
$("#Show").load('keepinformed.php',{fname: fname,email: email, gsm : gsm,send: "true"},function(){$('#Show').hide();$('#Show').slideDown(1000);});
  } else return Pass;
  };
 //-------------------------------------------------------------

function SubmitCall(){
	   var Pass =  validateForm_requestcall();
	   if (Pass == true){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
//$('#data').html('<div style="text-align:center"><img src="images/ajax-loader.gif"  /><\/div>');
var fname=document.getElementById("fname").value;
var gsm=document.getElementById("gsm").value;
var email=document.getElementById("email").value;
$("#Show").load('requestcall.php',{fname: fname,email: email, gsm : gsm,send: "true"},function(){$('#Show').hide();$('#Show').slideDown(1000);});
  } else return Pass;
  };
 //-------------------------------------------------------------

 function SubmitAppt(){
	   var Pass =  validateForm_bookapp();
	   if (Pass == true){
$.ajaxSetup({ 
		cache: false ,
		global: false,
	   	type: "POST"
});
//$('#data').html('<div style="text-align:center"><img src="images/ajax-loader.gif"  /><\/div>');
var fname=document.getElementById("fname").value;
var gsm=document.getElementById("gsm").value;
var appointmentfor=document.getElementById("appointmentfor").value;
var appointment_date=document.getElementById("appointment_date").value;
var email=document.getElementById("email").value;
$("#Show").load('bookappt.php',{fname: fname,email: email, gsm : gsm,appointment_date:appointment_date,appointmentfor : appointmentfor ,send: "true"},function(){$('#Show').hide();$('#Show').slideDown(1000);});
  } else return Pass;
  };
  //-------------------------------------------------------------------
function validateForm_contactus()
{
// check name
if (document.getElementById("fname").value == "")
{
alert ("Please Enter your Good Full Name!");
return false;
}

var strr=document.getElementById("email").value;
 var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

 if (!filter.test(strr)){
    alert("Please input a valid email address!");
	return false;
 }
if (document.getElementById("subject").value == "")
{
alert ("Please Enter Message Subject!");
return false;
} 
if (document.getElementById("message").value == "")
{
alert ("Please Enter Your Message!");
return false;
}

return true;
}
//-------------------------------------------------------------

function validateForm_keepinformed()
{
// check name
if (document.getElementById("fname").value == "")
{
alert ("Please Enter your Good Full Name!");
return false;
}

var strr=document.getElementById("email").value;
 var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

 if (!filter.test(strr)){
    alert("Please input a valid email address!");
	return false;
 }

return true;
}
//-------------------------------------------------------------

function validateForm_requestcall()
{
// check name
if (document.getElementById("fname").value == "")
{
alert ("Please Enter your Good Full Name!");
return false;
}

var strr=document.getElementById("email").value;
 var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

 if (!filter.test(strr)){
    alert("Please input a valid email address!");
	return false;
 }
 
if (document.getElementById("gsm").value == "")
{
alert ("Please Enter your Mobile Number!");
return false;
}

return true;
}
//-------------------------------------------------------------
function validateForm_bookapp()
{
// check name
if (document.getElementById("fname").value == "")
{
alert ("Please Enter your Good Full Name!");
return false;
}

var strr=document.getElementById("email").value;
 var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

 if (!filter.test(strr)){
    alert("Please input a valid email address!");
	return false;
 }
if (document.getElementById("gsm").value == "")
{
alert ("Please Enter your Mobile Number!");
return false;
}
if (document.getElementById("appointment_date").value == "")
{
alert ("Please Choose Your Appointment Date!");
return false;
}

return true;
}
function op_date(name)
{
	var width=302, height=220;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,';
    styleStr += 'width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	open("library/date/date.php?name="+name,"win",styleStr)
}

function SetOver(name){
	name.style.backgroundImage='url(images/buttonOver.jpg)';
	}
function SetDefault(name){
	name.style.backgroundImage='url(images/button.jpg)';
	}
//-------------------------------------------------------------

