var xyz="";
var hdx="";
var desc="";
var varURL=self.location.href;
var varPart=varURL.split('?');
var theurlpage=varURL;
var v_languagename="";
var v_foldername="";
var v_filename="";
if (varPart.length > 1)
{
	theurlpage=varPart[0];
	var varPart1=varPart[1].split('&');
	varPart2=varPart1[0].split('=');
	if (varPart2[0] == "id" && varPart2[1] != "")
	  var xyz=varPart2[1];
	else
	  var xyz="";
	if (varPart1.length > 1) {
		varPart3=varPart1[1].split('=');
		if (varPart3[0] == "jd" && varPart3[1] != "")
		  var hdx=varPart3[1];
		else
		  var hdx="";
	}
}
if (theurlpage.length > 1)
{
	turlpage=theurlpage.split("/");
	for(i=0; i < turlpage.length; i++) {
		if (v_filename =="")
			v_filename=turlpage[i];
		else
		{
			if (v_foldername=="")
			{
				v_foldername=v_filename;
				v_filename=turlpage[i];
			}
			else
			{
				v_languagename=v_foldername;
				v_foldername=v_filename;
				v_filename=turlpage[i];
			}
		}
	}
}

while (hdx.search("~") >= 0)
{
hdx=hdx.replace("~"," ");
}
while (desc.search("~") >= 0)
{
desc=desc.replace("~"," ");
}

function imgpath_replace(thevvv)
{
	var outvvv="";
	thevvv2=thevvv.toLowerCase();
	var tlen=thevvv2.length;
	if (tlen >= 13)
	{
		if (thevvv2.substring(0,13)=="media/images/")
		{
			if (tlen > 13)
				outvvv=urlreplace2 + thevvv.substring(13);
			else if (len==13)
				outvvv=urlreplace2;
		}
	}
	if (outvvv=="" && tlen >= 16)
	{
		if (thevvv2.substring(0,16)=="../media/images/")
		{
			if (tlen > 16)
				outvvv=urlreplace3 + thevvv.substring(16);
			else if (len==13)
				outvvv=urlreplace3;
		}
	}
	if (outvvv=="" && tlen >= 18)
	{
		if (thevvv2.substring(0,18)=="../cms_sync_media/")
		{
			if (tlen > 18)
				outvvv=urlreplace4 + thevvv.substring(18);
			else if (len==18)
				outvvv=urlreplace4;
		}
	}
	return outvvv;
}
function correct_scrollbar(thetextx)
{
	anyp=(thetextx.toLowerCase()).search("<p>");
	if (anyp >= 0)
	{
		if (anyp==0)
			thetextx="<p><a href=#><img src=../../images_new/shim.gif width=1 height=1 border=0></a>" + thetextx.substring(anyp + 3);
		else
			thetextx=thetextx.substring(0,anyp - 1) + "<p><a href=#><img src=../../images_new/shim.gif width=1 height=1 border=0></a>"  + thetextx.substring(anyp + 3);
	}
	else
		thetextx="<a href=#><img src=../../images_new/shim.gif width=1 height=1 border=0></a>" + thetextx;
	return thetextx;
}
function getImgSize(imgSrc,whatwant)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	var xheight = newImg.height;
	var xwidth = newImg.width;
	if (whatwant==1)
		return xheight;
	else
		return xwidth;
}

function getBrowserWindowSize(height_or_width)
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if (height_or_width==1)
		return myWidth;
	else
		return myHeight;
}

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
//dateFormat.i18n = {
//	dayNames: [
//		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
//		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
//	],
//	monthNames: [
//		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
//		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
//	]
//};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};

//alert (getBrowserWindowSize(0));
//alert(getBrowserWindowSize(1));

$(document).ready(function() {
	if (getBrowserWindowSize(0) < 600)
	{
		//$("#globaltable").css({"position":"relative"});
		$("#globaltable").css({"margin-top":"0px"});
		$("#globaltable").css({"top":"0"});
	}
	if (getBrowserWindowSize(1) < 1000)
	{
		//$("#globaltable").css({"position":"relative"});
		$("#globaltable").css({"margin-left":"0px"});
		$("#globaltable").css({"left":"0"});
	}
});

//DK resize reflection, 20110926
$(function(){
	//hotfix 20111114 for conflict with flash site
	if ( swfobject.hasFlashPlayerVersion( "10" ) )
		return;
		
	// init overflow setting
	$("body").css('overflow','hidden');
	if($(window).width()<1024 || $(window).height()<624)
		$("body").css('overflow','auto');
	
	//once resized, use timeout for hacking
	$(window).resize(function() {
		if(this.resizeTO) clearTimeout(this.resizeTO);
		this.resizeTO = setTimeout(function() {
			$(this).trigger('resizeEnd');
		}, 500);
		
		//update overflow status
		if($(window).width()<1024 || $(window).height()<624)
			$("body").css('overflow','auto');
	});

	$(window).bind('resizeEnd', function() {
		//do something, window hasn't changed size in 500ms
		window.location.href=window.location.href;
	});	

	//DK 1024-optimization
	//Table resize to 1024 browser
	if($(window).width()>=950 && $(window).height()>=624)
		$("body").css('overflow','hidden');
		
	$("#application").css("height","0");
	//min-width of content table: 1060px width is the critical problem
	if($(window).width()<"1060"){
		//change the default table width
		var tables = $("table[width=1060]");
		$.each(tables, function() { 
			$(this).attr("width","950");
		});

		$("img[name=shim1]").attr("width","950");

		if($(window).width()>="1000"){
			//alert("1000 --- $(window).width()="+$(window).width());
			$("img[name=shim1]").attr("width","1000");	
			//P.S.: $(window).width()-($(window).width()-$("img[name=shim1]").attr("width")-59) = x-(x-y-59) = y+59
		}else{
			if($(window).width()>="950" && $(window).width()<"1000"){
//				alert("980＜﹣＞1000 --- $(window).width()="+$(window).width());
				//change the default table width
				var tables = $("table[width=950]");	//as it is initially changed from 1060 to 950px
				$.each(tables, function() { 
					$(this).attr("width",$(window).width());
				});
	
				//for front-page only
				if(window.location.href.indexOf("index")>=0)
					$("img[name=shim1]").attr("width",$(window).width()-30);
				else
					$("img[name=shim1]").attr("width",$(window).width()-72);
				
				//for dinning and rooms page
				if(window.location.href.indexOf("rooms")>=0 ||
					window.location.href.indexOf("dining")>=0)
					$("table[width=650]").attr("width",$("img[name=shim1]").attr("width")-275);
	
				$("#application").css("width",$(window).width()-72);
			}else{
				//fit for other lower resolution
				var tables = $("table[width=950]");	//as it is initially changed from 1060 to 950px
				$.each(tables, function() { 
					$(this).attr("width","961");
				});
			
			}
		}
		
		// for some pages, there is space image sized 746. It should be tuned to 
		$("img[width=746]").attr("width",2*(746)-$(window).width()+20);
		
		//the promotion space image is too large
		if(window.location.href.indexOf("promo"))			
			$("img[width=60]").attr("width","40");
			
		//both the vune and request space image are too large
		if(window.location.href.indexOf("venue")>=0 ||
			window.location.href.indexOf("request")>=0)
			$("img[width=20]").attr("width","0");
	}
});

