if ( window.location.search ) {
   var query = window.location.search;
   if (query.substring(0,1) == '?') {
       query = query.substring(1);
       var data = query.split('=');
       if (data[0] == "popup"){ addPopup("http://rodeodrive-bh.com"+data[1],'');}
   }
}
function addPopup(file,url,w,h,bg){
	ext = getFileExtension(file);
	//alert (ext);
		if (ext == "swf"){
                        if (!w){w="300"}
                        if (!h){h="400"}
			popup='<div style="margin:5px;"><object width="'+w+'" height="'+h+'"><param name="wmode" value="transparent" ></param><param name="FlashVars" value="clickTAG='+url+'"></param><param name="movie" value="'+file+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+file+'" FlashVars="clickTAG='+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="'+w+'" height="'+h+'"></embed></object></div>';	
		}else if (ext == "jpg" || ext=="gif" || ext=="png"){
                if (!w){w="500"}
                if (!h){h="500"}
		popup= '<a href="'+url+'"><img width="'+w+'" height="'+h+'" align="right" style="margin:5px;"  src="'+file+'"/></a>';
	        }else{
                 if (!w){w="500"}
                 if (!h){h="500"}
                 if (!bg){bg="transparent"}
                popup='<iframe src="'+file+'" width="'+w+'" height="'+h+'" frameborder="0" style="background: '+bg+'">Iframes are not supported by your browser</iframe>';
}

	
//default popup //-- popup= '<img style="margin:15px;"  src="'+file+'"/>';

 if (window.pageContent) {
   document.getElementById('popupbg').style.display = "block";
         document.getElementById('popup').style.display = "block";
        document.getElementById('popdata').innerHTML = popup;
 }else{
if (!w){w="300"}
if (!h){h="400"}
window.pageContent = document.getElementsByTagName('body')[0].innerHTML;
window.popupWin='<a href="javascript:closepopup();" id="popupbg" style="z-index:98;position:absolute;top:0;left:0;width:100%;height:100%;background:url(images/bg.png);"></a><div id="popup" style="z-index:98;left:0;top:0;position:absolute;width:100%;height:100%; background: transparent;"><div style="position:relative;z-index:99; padding:15px; margin:15% auto; width:'+w+'px;height:'+h+'px; text-align:right;"><span id="popdata">'+popup+'</span><a style="position:absolute;top:0px;left:0px; z-index:999;" href="javascript:closepopup();"><img src="images/close.png"/></a></div></div>';

document.getElementsByTagName('body')[0].innerHTML+= window.popupWin;
 }
}


function closepopup(){  
        if(window.location.search){
           // window.location =  window.location.toString().replace(window.location.search.toString(),'');
        }
      // document.getElementsByTagName('body')[0].innerHTML = window.pageContent;

         //bodyStr = document.getElementsByTagName('body')[0].innerHTML;
       // document.getElementsByTagName('body')[0].innerHTML = bodyStr.replace(window.popupWin,"");

         document.getElementById('popupbg').style.display = "none";
         document.getElementById('popup').style.display = "none";
         
      
}
function getFileExtension(filename)
{
  var ext = /^.+\.([^.]+)$/.exec(filename);
  return ext == null ? "" : ext[1];
}

