/* 
 Chris McKee
 Virtual Tour PropDetails Override
 $LastChangedRevision: 1335 $
*/
(function vtOverRide() {
	try{		
		var htv = document.getElementById("hypVirtualTour");
		if(htv)
		{
			var popupURL = htv.getAttribute("onclick");
				  var re1='.*?';	// Non-greedy match on filler
				  var re2='(\\\'.*?\\\')';	// Single Quote String 1
				  var p = new RegExp(re1+re2,["i"]);
				  var m = p.exec(popupURL);
				  if (m != null)
				  {
					  var strng1=m[1];
					  popURL = strng1.replace(/'/g,'');
				  }
				  
			var w = "830",
			    h = "698";
			
			var standard = /VirtualTour.aspx/gi,
				gres = standard.test(popURL);
			if(gres){w="430"; h="440"; }
			
			//EHOUSE Override
			var ehouse =/ehouse/gi,
			    eres = ehouse.test(popURL),
				ehouseprem = /.html/gi,
				eresb = ehouseprem.test(popURL);
				
			if(eres){ 
				w="430"; h="440"; 
				if(eresb){ w="850"; h="720"; }
			}
			
			//Flash Factory (SPAIN) Override
			var flashFactory = /360Factory/gi,
			    fres = flashFactory.test(popURL);
			
			//Scotland 360 Override
			var flashScotland = /360Scotland/gi,
			    fscot = flashScotland.test(popURL);
				
			if(fscot){ w="680"; h="480"; }

			popURL = popURL + "?keepthis=true&tb_iframe=true&height=" + h + "&width=" + w;
			if(eres || fscot)
			{
				htv.href = "javascript:void(window.open('"+popURL+"','VirtualTours','resizable=yes,scrollbars=no,status=no,width="+w+",height="+h+",centerscreen=true'));";
			}
			else
			{
				htv.href = "javascript:void($.thickbox_open('Virtual Tours', '"+popURL+"',''));";
			}
			htv.setAttribute("onclick", "_gaq.push(['_trackEvent', 'VirtualTour', 'PropertyDetailsPage']);");
		}
		delete htv;
	}catch(e){ console.log(e); }
})();
