﻿
var urlname=window.location.host;

var result =urlname.indexOf("arabic.mozabintnasser.qa");
var resultex =urlname.indexOf("10.5.5.11");
var cheackValidEmail="";
var cheackEmailEnterd="";
var cheacksubscribedsuccessfully="";
var cheacksubscribeExist="";
var lang="";

var isEnSite = urlname.indexOf("www.mozabintnasser.qa");
var isArSite = urlname.indexOf("arabic.mozabintnasser.qa");
var SiteActionMenuHeaderDiv = document.getElementById('SiteActionMenuHeaderDiv');
if(isEnSite != -1 || isArSite != -1){
    if(SiteActionMenuHeaderDiv){
        SiteActionMenuHeaderDiv.style.display = "none";
    }
}

 
 if (result==-1 && resultex==-1 ){
 
 ReturnCultureResources("1")
 cheackValidEmail="Enter a valid email address please";
  cheackEmailEnterd="Please Enter your Email";
  cheacksubscribedUser="you have subscribed successfully";
  cheacksubscribedsuccessfully="you have subscribed successfully";
  cheacksubscribeExist="This email address already subscribed";
   lang="1";

 }
 else
 {
 
 ReturnCultureResources("0")
 cheackValidEmail="الرجاء إدخال البريد الإلكتروني بالشكل المناسب";
 cheackEmailEnterd="الرجاء إدخال البريد الإلكتروني";
 cheacksubscribedsuccessfully="تمت عملية الإشتراك بنجاح";
 cheacksubscribeExist="لقد قمت بالإشتراك في هذا البريد الإلكتروني من قبل";
 lang="0";
  
 }




function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		

		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		
		
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		     document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
  
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		     document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		        document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		          document.getElementById("msg").innerHTML=cheackValidEmail;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.getElementById("txtSubscribe");
	
	if ((emailID.value==null)||(emailID.value=="")){
		document.getElementById("msg").innerHTML=cheackEmailEnterd;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
	
		emailID.focus()
		return false
	}
	Subscribe();
	return true
 }


function Subscribe()
  {
  
  
  
  
  
var emailID=document.getElementById("txtSubscribe");
    

 iHorizonsGeneralWebService.GeneralWebService.SubScribeNewsletter(emailID.value,lang,OnCompleteNewsletter,OnErrorNewsletter,OnTimeOutNewsletter);
 
  
  
  }
  
  function OnCompleteNewsletter(arg)
  {

  if (arg=='{"Result":{"value":"1"}}'){
  
  document.getElementById("msg").innerHTML=cheacksubscribedsuccessfully;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
  
  }
  else
  {
   document.getElementById("msg").innerHTML=cheacksubscribeExist;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
  
  }


  
  }
  
  function OnTimeOutNewsletter(arg) {
            document.getElementById("msg").innerHTML="timeOut has occured";
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
        }
        
  function OnErrorNewsletter(arg) {
            document.getElementById("msg").innerHTML="error has occured: " + arg._message;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
        }
        
   //get resource file 
   
   function ReturnCultureResources(lang){
   
   if(lang=="1")
   {
 iHorizonsGeneralWebService.GeneralWebService.ReturnCultureResources("en",OnCompleteReturnCultureResources,OnErrorReturnCultureResources,OnTimeOutReturnCultureResources);
 
   }
   
   else
   {
    iHorizonsGeneralWebService.GeneralWebService.ReturnCultureResources("ar",OnCompleteReturnCultureResources,OnErrorReturnCultureResources,OnTimeOutReturnCultureResources);
   
   }
   
   
   }
   
   function OnCompleteReturnCultureResources(arg){
  





 
  var Resources= eval("(" + arg + ")"); 

  
  if(document.getElementById("homeanchour") !=null)
  {
    var homeanchour=document.getElementById("homeanchour");
   homeanchour.href=Resources.Resources.Resource[4].Value;
  
  }
   if(document.getElementById("iframGallaryHid") !=null)
      document.getElementById("iframGallaryHid").value=Resources.Resources.Resource[0].Value;
      
   if(document.getElementById("iframGallaryVideoshid") !=null)
      document.getElementById("iframGallaryVideoshid").value=Resources.Resources.Resource[1].Value;
   if(document.getElementById("hidSitePublishUrl") !=null)
      document.getElementById("hidSitePublishUrl").value=Resources.Resources.Resource[3].Value;
      
   if(document.getElementById("hidSiteUrl") !=null)
     document.getElementById("hidSiteUrl").value=Resources.Resources.Resource[2].Value;
     
//   if(document.getElementById("hrefcheckEventsCalc") !=null)
//   {
//   var hrefcheckEventsCalc=document.getElementById("hrefcheckEventsCalc");
//   hrefcheckEventsCalc.href=Resources.Resources.Resource[5].Value;

//   }
//   if(document.getElementById("hrefcheckEventsList") !=null)
//   {
//   var hrefcheckEventsList=document.getElementById("hrefcheckEventsList");
//   hrefcheckEventsList.href=Resources.Resources.Resource[5].Value;

//   }
   
   
  
   if(document.getElementById("hrefDetails") !=null)
   {
        var hrefDetails=document.getElementById("hrefDetails");
        
        hrefDetails.href= Resources.Resources.Resource[8].Value;
      
  }

    
   }
   
   
    function OnTimeOutReturnCultureResources(arg) {
            document.getElementById("msg").innerHTML="timeOut has occured";
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
        }
        
  function OnErrorReturnCultureResources(arg) {
           document.getElementById("msg").innerHTML="error has occured: " + arg._message;
		
		$('#msg').modal();
		$('#simplemodal-container').css("width","500px");
		$('#simplemodal-container').css("height","150px");
        }
        
   
   
   function goToBookMark(BookMarkName){
    document.location.href = document.location.href.split("#")[0]+ "#" + BookMarkName;
  }
  
