
var mainaddress=window.location.href.slice(0,window.location.href.indexOf("#",0));
var presaddress=window.location.href;
var flagforasp_iframe;
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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			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();

function changeurl(e)
{	
	flagforasp_iframe=1;
	var event;
	var id,url,href;
	 
	event=(window.event)?(window.event):e;
	{
		if (BrowserDetect.browser!="Firefox")
		{
			id=event.srcElement.id;
			url=event.srcElement.url;
			 href=event.srcElement.href;
		}
		else
		{
			id=event.target.id;
			 url=event.target.url;
			 href=event.target.href;
		}
	}
	
	//alert("----id== "+id+"--href== "+href+"--"+url);
	
	if(presaddress.indexOf("#")== -1)
	{	//alert(href+"#"+id+".pointcross");
	var corurl=href+"#"+id+".pointcross";
	window.location = corurl;
	}
	else if (presaddress.indexOf("#") >-1 && presaddress.split("#")[1].indexOf(".pointcross")== -1)
	{ 
	     var corurl=href+"#"+id+".pointcross";
	     window.location = corurl;
	}
	
	else
	{
		parent.window.location.href=mainaddress+"#"+id+".pointcross";
		addPerson(id);
	}
	return false;
}
function loadmap()
{	

	var currentmainurl=window.location.href;
	
	var lengthofstr=currentmainurl.length;
	var location=currentmainurl.indexOf("#",1);
	var locdot=currentmainurl.lastIndexOf(".");
	var urlid=currentmainurl.substring(location+1,locdot);
	addPerson(urlid);
}
var iLoadFlexCnt =0;
function addPerson(id)
{	
    var flag;
	
    iLoadFlexCnt++;
    try
    {
    flag= getFlexApp("main").addPerson(id);
	if(flag != 1)
	{
	    if(iLoadFlexCnt<100)
	    setTimeout(function(){addPerson(id)},500);
	}
    }
    catch(e)
    {
		setTimeout(function(){addPerson(id)},500);
	 }
}
function getFlexApp(appName)
{
	if (navigator.appName.indexOf ("Microsoft") !=-1) 
	{
		return window[appName];
	} 
	else 
	{
		return document[appName];
	}
}
function sendToJavaScript(value,url)
{	
	
	var curnturl;
	curnturl = parent.window.location.href;
	
	if(curnturl.indexOf("#"+value)==-1)
	{
		parent.window.location.href="#"+value+".pointcross";
		document.getElementById('content').style.display="none";
		
		document.getElementById('myframe').style.display="";
		frames['myframe'].location.href = url.substring(0);
		//loadXMLDoc(url);
	}
	if(curnturl.indexOf("#") != -1 && curnturl.indexOf("?") != -1 && flagforasp_iframe==1)
	{
		
		document.getElementById('content').style.display="none";
		//loadXMLDoc(url);
		document.getElementById('myframe').style.display="";
		frames['myframe'].location.href = url.substring(0);
		flagforasp_iframe = 0;
	}
	
}
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,false);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}
function state_Change()
{
		if (xmlhttp.readyState==4)
		{// 4 = "loaded"
			if (xmlhttp.status==200)
			{// 200 = "OK"
				document.getElementById('jscontent').innerHTML=xmlhttp.responseText;
			}
			else
			{
				alert("Problem retrieving data:" + xmlhttp.statusText);
			}
		}
	}
//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
//document.getElementById(iframeid).src=url
frames['myframe'].location.href = url;
}
var flag="1";
function refreshing()
	{
	alert(flag);
	if(flag == "1")
	setTimeout( "refresh()", 10000 );
	flag = "0";
	
}


function refresh()
{
   
    window.location.reload(true);
}

// not needed
function AdjustFrameHeight()
{ 
    var IFrame= document.getElementById("myframe");
    var iFrameDoc=(IFrame.contentWindow.document)?(IFrame.contentWindow.document):(IFrame.contentDocument);
    if (IFrame.contentDocument) //ns6 syntax
        {
            IFrame.style.height = IFrame.contentDocument.body.offsetHeight+16; 
            IFrame.style.cssText=IFrame.style.cssText+"overflow-x:hidden;overflow-y:hidden";

        }
     else{
            try{IFrame.style.height=IFrame.contentWindow.document.body.scrollHeight;}catch(e){}
        }
     iFrameDoc.body.onclick=function A(){AdjustFrameHeight()};
}
function setHeight(obj,val)
{
   // obj.style.height=val+'px';
   document.getElementById("myframe").style.height=val+'px';;
}

