﻿var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var browserName=BrowserDetect.browser; 
//alert(BrowserDetect.browser);

var BN="";
if (browserName=="Netscape")
{ 
   BN="NC";
}
else if (browserName=="Explorer")
   {
        BN="IE";
   }
else if (browserName=="Firefox" || browserName=="Mozilla")
  {
    BN="FF"; 
  }

window.defaultStatus="Welcome To MSApple Web Page";

function msMouse()
{
alert("test");
  window.status="Welcome To MSApple Web Page";
}

function TXT_Clear(obj){
obj.value="";
}

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){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true
	}

function ValidateForm(path,inpu){
//alert(path);
 if (inpu != "Open")
 {
	var emailID=document.getElementById(inpu);
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	//window.showModelessDialog("http://localhost/layouts/msapple/emailSignUp.aspx");
	//window.open('http://msa.innismaggiore.com' + path + '?email=' + emailID.value ,'mywindow','top=100,left=200,width=581,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
	window.open('http://www.msapple.com' + path + '?email=' + emailID.value ,'mywindow','top=100,left=200,width=581,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
  }
  else
  {
       var event_tit=document.getElementById("event_tit");
       if (event_tit !=null)
       {
	      //window.showModelessDialog("http://localhost/layouts/msapple/emailSignUp.aspx");
	      //window.open('http://msa.innismaggiore.com' + path + '?title=' + event_tit.innerText ,'mywindow','top=100,left=300,width=581,height=570,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
	      window.open('http://www.msapple.com' + path + '?title=' + event_tit.innerText ,'mywindow','top=100,left=300,width=581,height=570,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
	   }
	   else
	   {
	           //window.open('http://msa.innismaggiore.com' + path ,'mywindow','top=100,left=300,width=581,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
	           window.open('http://www.msapple.com' + path ,'mywindow','top=100,left=300,width=581,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes, resizable=no');
	   }
  }
 }

function animationImg()
{
   //In future Please Increase the count or get the value from CMS
   for(i=1;i<=4;i++)
   {
        var str="adimg" + i;
     if (ms_img_count == i)
     {
        var img_obj=document.getElementById(str);
        if (img_obj!= null)
            img_obj.className="adImage_show";
     }
     else
     {
        var img_obj=document.getElementById(str);
        if (img_obj!= null)
            img_obj.className="adImage";
     }
   }
   if (ms_img_count==4)
   {
      ms_img_count=0;
   }
   ms_img_count++;

/*    if (ms_img_count == 1) 
    {
        mainform.adimg1.className="adImage_show";
        mainform.adimg2.className="adImage";
        mainform.adimg3.className="adImage";
        mainform.adimg4.className="adImage";
    }
    else if (ms_img_count == 2)
    {
        mainform.adimg2.className="adImage_show";
        mainform.adimg1.className="adImage";
        mainform.adimg3.className="adImage";
        mainform.adimg4.className="adImage";
    }
    else if (ms_img_count == 3)
    {
        mainform.adimg3.className="adImage_show";
        mainform.adimg2.className="adImage";
        mainform.adimg1.className="adImage";
        mainform.adimg4.className="adImage";
    }
    else if (ms_img_count == 4)
    {
        mainform.adimg4.className="adImage_show";
        mainform.adimg2.className="adImage";
        mainform.adimg3.className="adImage";
        mainform.adimg1.className="adImage";
        ms_img_count=0;
    }
    ms_img_count++;*/
}

function msBusinessMenu()
{
    if (BN != "IE")
    {
      // alert(BN);
       var msbuobj = document.getElementById("msBCPA");
       msbuobj.className="homBusinessMenuTable_NC";
       var msbuobj = document.getElementById("msBVS");
       msbuobj.className="homBusinessMenuTable_NC";
       var msbuobj = document.getElementById("msBBS");
       msbuobj.className="homBusinessMenuTable_NC";
    }
    //document.swf.focus();
}

//Financial Calculator
function viewMenu(c)
{
    //alert(document.URL);
	document.link_form.m.value = document.URL;
	document.link_form.action="http://www.execusite.com/engine/tools/index.cfm?args=M9~5E~25~2A~5DJ~21~3AX~2AB~3AN~2B~40AFT14L~2CU~21UX8~2CD~3AR~40OIO~23Y~5C~3FLQP~3B9~3B~21~2F~3EISJ6~3DZ8~28RI~3C6~0A~3AC~3A~2C~3BB~40ES~3EHN~21~40KB4M~29~3BOHLS~2C~27~28~29~23V~2FV1JXL~20~0A&c=" + c;
	document.link_form.submit();
}