﻿//http://blog.johnmckerrell.com/2006/10/22/resizing-iframes-across-domains/

function updateIFrame(height) {
	var iframe = document.getElementById('myiframe');
	//iframe.setAttribute('height', height );
	document.getElementById('ctl00_cpMain_myiframe').height = height + 'px';
}

function GetURL(){
	var iframe = document.getElementById('ctl00_cpMain_myiframe');
	var iFrameURL = iframe.src;

	var myQuery = new QueryString();
	myQuery.read();
	rExp = /showitem=1/gi;
	rExp2 = /ss=/gi;
	if(myQuery.getStatus()){
		var sHtml = "";
		var aQueryData = myQuery.getAll();
		for(var n in aQueryData){
		sHtml += "&" + n + "=" + aQueryData[n];
		results = sHtml.search(rExp);
		results2 = sHtml.search(rExp2);
		}
		if (results > -1){
			iFrameURL = iFrameURL.toLowerCase();
			iFrameURL = iFrameURL.replace("showroom_find.aspx","showroom_viewdetail.aspx");
			iFrameURL = iFrameURL + sHtml
			iframe.src = iFrameURL;
		}
		if (results2 > -1) {
		    pausecomp(1500);
		    iFrameURL = iFrameURL.toLowerCase();
		    iFrameURL = iFrameURL.replace("showroom_find.aspx", "showroom_find.aspx?sstring=" + aQueryData[n] + "&");
		    iFrameURL = iFrameURL + sHtml
		    iframe.src = iFrameURL;
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
var oldHeight = 111;
function watchFrame(){
	var iframe = document.getElementById('myiframe');
	var myURL = window.location.href;
	var newHeight = 500;	
	start = myURL.search('#');
	end = myURL.search('XXX');
	newHeight = myURL.substring(start+1,end);
	
	if (newHeight !== '' && newHeight !== oldHeight){
		document.getElementById('ctl00_cpMain_myiframe').height  = newHeight + 'px';
		oldHeight = newHeight;
	}
}
//setInterval("watchFrame();", 10)
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
function pausecomp(millis) {
    //http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while (curDate - date < millis);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////


