//allowtransparency to iframes
onload = function() {
	var theframes = document.getElementsByTagName('iframe');
	for (var i = 0; i < theframes.length; i++)
		theframes[i].setAttribute("allowTransparency", "true");

}


////google script


//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


//try {
//	var pageTracker = _gat._getTracker("UA-11449447-3");
//	pageTracker._trackPageview();
//} catch (err) { }

//preload images

function MM_preloadImages() { //v3.0
	var d = document; if (d.images) {
		if (!d.MM_p) d.MM_p = new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
	}
}


//-------------- AC_RunActiveContent ----------------//

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext) {
	if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext + '?');
	else
		return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) {
	var str = '<object ';
	for (var i in objAttrs)
		str += i + '="' + objAttrs[i] + '" ';
	str += '>';
	for (var i in params)
		str += '<param name="' + i + '" value="' + params[i] + '" /> ';
	str += '<param name="WMODE" value="transparent">';
	str += '<embed ';
	for (var i in embedAttrs)
		str += i + '="' + embedAttrs[i] + '" ';
	str += ' WMODE="transparent"></embed></object>';

	document.write(str);
}

function AC_FL_RunContent() {
	var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_WMV_RunContent() {
	var ret = AC_GetArgs(arguments, "", "src", "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95", "application/x-oleobject");
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
	var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
	var ret = new Object();
	ret.embedAttrs = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();
	for (var i = 0; i < args.length; i = i + 2) {
		var currArg = args[i].toLowerCase();

		switch (currArg) {
			case "classid":
				break;
			case "pluginspage":
				ret.embedAttrs[args[i]] = args[i + 1];
				break;
			case "src":
			case "movie":
				args[i + 1] = AC_AddExtension(args[i + 1], ext);
				ret.embedAttrs["src"] = args[i + 1];
				ret.params[srcParamName] = args[i + 1];
				break;
			case "onafterupdate":
			case "onbeforeupdate":
			case "onblur":
			case "oncellchange":
			case "onclick":
			case "ondblClick":
			case "ondrag":
			case "ondragend":
			case "ondragenter":
			case "ondragleave":
			case "ondragover":
			case "ondrop":
			case "onfinish":
			case "onfocus":
			case "onhelp":
			case "onmousedown":
			case "onmouseup":
			case "onmouseover":
			case "onmousemove":
			case "onmouseout":
			case "onkeypress":
			case "onkeydown":
			case "onkeyup":
			case "onload":
			case "onlosecapture":
			case "onpropertychange":
			case "onreadystatechange":
			case "onrowsdelete":
			case "onrowenter":
			case "onrowexit":
			case "onrowsinserted":
			case "onstart":
			case "onscroll":
			case "onbeforeeditfocus":
			case "onactivate":
			case "onbeforedeactivate":
			case "ondeactivate":
			case "type":
			case "codebase":
				ret.objAttrs[args[i]] = args[i + 1];
				break;
			case "width":
			case "height":
			case "align":
			case "vspace":
			case "hspace":
			case "class":
			case "title":
			case "accesskey":
			case "name":
			case "id":
			case "tabindex":
				ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
				break;
			default:
				ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
		}
	}
	ret.objAttrs["classid"] = classid;
	if (mimeType) ret.embedAttrs["type"] = mimeType;
	return ret;
}

//-------------- slideDivs -------------------//


function crawl() {
	var el = document.getElementById("tblWrapper");
	var pos = FindPos(el);
	var divCrawl = document.getElementById("crawlDown");
	divCrawl.style.left = parseInt(pos[0]) + "px";
	divCrawl.style.top = parseInt(pos[1]) + "px";


	divCrawl.style.display = "block";

	if (parseInt(divCrawl.style.height.replace("px", "")) > 0)
		slideDiv(divCrawl, true);
	else
		slideDiv(divCrawl, false);

}


function slideDiv(divToSlide, close) {
	if (!close) {

		//slideMapDiv(document.getElementById('DivMap'), true);
		if (parseInt(divToSlide.style.height.replace("px", "")) < 331) {

			try {
				divToSlide.style.height = (parseInt(divToSlide.style.height.replace("px", "")) + 5) + "px";
				timeoutHotels = setTimeout(function() { slideDiv(divToSlide, close); }, 1);
			}
			catch (err) {
			}
		}
		else {
			divToSlide.style.height = "332px";
		}
	}
	else {
		if (parseInt(divToSlide.style.height.replace("px", "")) - 5 > 0) {
			try {
				divToSlide.style.height = (parseInt(divToSlide.style.height.replace("px", "")) - 5) + "px";
				timeoutHotels = setTimeout(function() { slideDiv(divToSlide, close); }, 1);
			}
			catch (err) {
			}
		}
		else {
			divToSlide.style.height = "0px";
			divToSlide.style.display = "none";
		}
	}
}


function FindPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft, curtop];
}


function crawlMap() {
	var el = document.getElementById("tblWrapper");
	var pos = FindPos(el);
	var divCrawl = document.getElementById("DivMap");
	divCrawl.style.left = parseInt(pos[0]) + "px";
	divCrawl.style.top = parseInt(pos[1]) + "px";

	divCrawl.style.display = "block";

	if (parseInt(divCrawl.style.width.replace("px", "")) > 0) {
		slideMapDiv(divCrawl, true);
	}
	else {
		slideMapDiv(divCrawl, false);
	}
}

function slideMapDiv(divToSlide, close) {
	if (!close) {
		slideDiv(document.getElementById('crawlDown'), true);
		if (parseInt(divToSlide.style.width.replace("px", "")) < 571) {
			divToSlide.style.width = (parseInt(divToSlide.style.width.replace("px", "")) + 5) + "px";
			divToSlide.style.height = "331px";
			setTimeout(function() { slideMapDiv(divToSlide, close); }, 1);
		}
		else {
			divToSlide.style.width = "571px";
		}
	}
	else {
		if (parseInt(divToSlide.style.width.replace("px", "")) - 5 > 0) {
			divToSlide.style.width = (parseInt(divToSlide.style.width.replace("px", "")) - 5) + "px";
			setTimeout(function() { slideMapDiv(divToSlide, close); }, 1);
		}
		else {
			divToSlide.style.width = "0px";
			divToSlide.style.display = "none";
		}
	}
}

function slideBannerBt() {
	var bodyElement = document.documentElement ? document.documentElement : document.body;
	//alert(screen.availHeight)
	var bodyheight = window.innerHeight ? window.innerHeight : bodyElement.clientHeight;

	if (document.getElementById("slideBannerBt").currentStyle)
		elHeight = document.getElementById("slideBannerBt").currentStyle.height;
	else
		if (document.defaultView.getComputedStyle) {
		elHeight = document.defaultView.getComputedStyle(document.getElementById("slideBannerBt"), '').height
	}

	elHeight = eval(elHeight.replace('px', ''));

	document.getElementById("slideBannerBt").style.top = (bodyElement.scrollTop + bodyheight - elHeight) + "px";
	document.getElementById("slideBannerBt").style.width = bodyElement.clientWidth;
	document.getElementById("slideBannerBt").style.backgroundColor = '#e6e6e6';


}

//----------------- PopUp.js --------------------------------------------//

function PopUp(width, height, value, header, isURL, isClosable, isFetchedOut) {
	if (typeof (isURL) == "undefined")
		isURL = true;
	if (typeof (isClosable) == "undefined")
		isClosable = true;
	if (typeof (width) == "undefined")
		width = 640;
	if (typeof (height) == "undefined")
		height = 480;
	if (typeof (isFetchedOut) == "undefined")
		isFetchedOut = true;
	if (typeof (value) == "undefined") {
		value = "<h1 style='font-size:36; color:red; font-weight:bold;'></h1>"
		isURL = false;
		isClosable = false;
		isFetchedOut = true;
		width = 640;
		height = 480;
	}

	if (isFetchedOut) {
		document.documentElement.style.overflowX = "hidden";
		document.documentElement.style.overflowY = "hidden";
		document.documentElement.style.overflow = "hidden";
	}

	var divBack = document.getElementById("divBack");
	var divFront = document.getElementById("divFront");
	var ifrPopUp = document.getElementById("ifrPopUp");
	var btnClose = document.getElementById("btnClose");
	var spnHeader = document.getElementById("spnPopUpHeader");

	var bodyElement = document.documentElement;
	divBack.style.width = bodyElement.clientWidth + "px";
	divBack.style.height = (bodyElement.scrollTop + bodyElement.clientHeight) + "px";
	divBack.style.display = isFetchedOut ? "block" : "none";
	divFront.style.width = width + "px";
	divFront.style.height = (height + (isClosable ? 22 : 0)) + "px";
	divFront.style.left = (bodyElement.clientWidth - width) / 2 + "px";
	divFront.style.top = (bodyElement.scrollTop + (bodyElement.clientHeight - (height + (isClosable ? 22 : 0))) / 2) + "px";
	divFront.style.display = "block";
	ifrPopUp.width = width + "px";
	ifrPopUp.height = height + "px";

	if (isURL) {
		ifrPopUp.src = value;
	}
	else {
		var ifrPopUpBody = IframeBody();
		ifrPopUpBody.style.overflow = "hidden";
		ifrPopUpBody.style.marginTop = "0px";
		ifrPopUpBody.style.marginRight = "0px";
		ifrPopUpBody.style.marginBottom = "0px";
		ifrPopUpBody.style.marginLeft = "0px";

		var div = document.createElement("div");
		div.style.width = "100%";
		div.innerHTML = value;
		ifrPopUpBody.innerHTML = "";
		AppendChild(ifrPopUpBody, div);
	}

	if (!isClosable) {
		btnClose.style.display = "none";
	}

	spnHeader.innerHTML = header;

	var oldOnResize = window.onresize;
	if (!oldOnResize) {
		window.onresize = function() { resize(width, height, isClosable); };
	}
	else {
		window.onresize = function() {
			oldOnResize();
			resize(width, height, isClosable);
		}
	}
}

function AppendChild(Obj, Child) {
	if (Child.outerHTML)
		Obj.innerHTML = Child.outerHTML;
	else
		Obj.appendChild(Child);
}

function IframeBody() {
	var ifr = document.getElementById("ifrPopUp");
	var rv;
	if (document.getElementById("ifrPopUp").contentDocument) {
		rv = document.getElementById("ifrPopUp").contentDocument;
	}
	else {
		// IE 
		rv = document.frames["ifrPopUp"].document;
	}

	var bodies = rv.getElementsByTagName("body");
	var body = bodies[0];

	body.style.marginTop = 0;
	body.style.marginLeft = 0;
	body.style.marginBottom = 0;
	body.style.marginRight = 0;

	return body;
}

function resize(width, height, isClosable) {
	document.documentElement.style.overflow = "hidden";
	var divBack = document.getElementById("divBack");
	var divFront = document.getElementById("divFront");

	var bodyElement = document.documentElement;
	divBack.style.width = bodyElement.clientWidth + "px";
	divBack.style.height = (bodyElement.scrollTop + bodyElement.clientHeight) + "px";
	divFront.style.left = (bodyElement.clientWidth - width) / 2 + "px";
	divFront.style.top = (bodyElement.scrollTop + (bodyElement.clientHeight - (height + (isClosable ? 22 : 0))) / 2) + "px";
}
