
function OverlayWindow(pId, pTitle, pDOM, pDOMTarget, pPropArr) {
    if (typeof(pId) == 'undefined') { alert('Overlay Window Error: pId undefined'); return false; } 
    if (typeof(pTitle) == 'undefined') pTitle = "";
    if (typeof(pContent) == 'undefined') pContent = "";
    
    if (typeof(pPropArr) == 'undefined') {
        pPropArr = new Array();
        pPropArr['border-color'] = "#404040";
        pPropArr['overflow-y'] = 'auto';
    } else {
        if (typeof(pPropArr['border-color']) == 'undefined') pPropArr['border-color'] = "#404040";
        if (typeof(pPropArr['overflow-y']) == 'undefined') pPropArr['overflow-y'] = "auto";
    }
    
    if (typeof(pHeaderBorderColor) == 'undefined') pHeaderBorderColor = "#8c556f";
    if (typeof(pOverflowY) == 'undefined') pOverflowY = "auto";
    
    if (typeof(pDOMTarget) == 'undefined') pDOMTarget = "Body";
    
    jQuery(pDOMTarget).append('<div onclick="jQuery(\'#'+pId+'\').remove(); jQuery(\'#'+pId+'_dvOverlay\').remove();" style="width: 100%; height: 100%; background: #000; position: fixed; top: 0; left: 0; z-index: 98; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7" id="'+pId+'_dvOverlay"></div>');
    //jQuery(pDOMTarget).append('<div style="width: 100%; height: 100%; background: #000; position: fixed; top: 0; left: 0; z-index: 98; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7" id="'+pId+'_dvOverlay"></div>');
    
    var shtml = "";
    shtml += "<div id=\""+pId+"\" style=\"width: auto; height: auto; background-color: #ffffff; border-style: solid; border-color: "+pPropArr['border-color']+"; border-width: 2px; display: none; z-index: 100;\">";
    shtml += "<div id=\""+pId+"_header\" style=\"clear: both; float: left; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; background-color: "+pPropArr['border-color']+";\">";
    shtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    shtml += "  <tr style=\"color: #ffffff; font-weight: bold\">";
    shtml += "    <td id=\""+pId+"_Title\">"+pTitle+"</td>";
    shtml += "    <td align=\"right\"><a href=\"javascript: void(0)\" onclick=\"jQuery('#"+pId+"_dvOverlay').remove(); jQuery('#"+pId+"').remove();\"><img src=\"images/overlayClose.gif\" name=\""+pId+"_ImgClose\" width=\"11\" height=\"11\" border=\"0\" id=\""+pId+"_ImgdvPopMsgClose\" /></a></td>";
    shtml += "  </tr>";
    shtml += "</table>";
    shtml += "</div>";
    shtml += "<div id=\""+pId+"_content\" style=\"clear: both; width: auto; background-color: #ffffff; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; overflow-y: hidden; overflow-x: hidden\">";
    shtml += '';
    shtml += "</div></div>"
    jQuery(pDOMTarget).append(shtml);
    jQuery("#"+pId+"_content").append(pDOM);
       
    
    jQuery("#"+pId+'_dvOverlay').fadeTo("slow", 0.33, function () {
    	jQuery("#"+pId).css("position", "absolute");  
        jQuery("#"+pId).fadeIn("fast");
        var tBGColor = jQuery("#"+pId+'_content').contents().css('background-color');
        if (tBGColor != '') jQuery("#"+pId+'_content').css('background-color', tBGColor);
        var tWidth = jQuery("#"+pId+'_content').contents().width();
        jQuery("#"+pId+'_content').css('width', tWidth);
        jQuery("#"+pId+'_header').css('width', tWidth);
        jQuery("#"+pId).css("top", jQuery(window).scrollTop()+((jQuery(window).height()/2)-(jQuery("#"+pId).height()/2))); 
        jQuery("#"+pId).css("left", jQuery(window).scrollLeft()+((jQuery(window).width()/2)-(jQuery("#"+pId).width()/2)));
        jQuery("#"+pId).css("z-index", 100);
    });   
}

function callPromo(pTarget, pData) {
    var tObj = jQuery('<table width="640" style="background-color: #000000; width: 640px;" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top" style="background-image:url(images/popup_texture.jpg); background-repeat:no-repeat; height: 480px;" id="PrData"></td></tr></table>');
	OverlayWindow('temp_id', 'Promo', tObj);
    jQuery('#PrData').append('Loading ...');
    
	jQuery.post(pTarget, 'id='+pData,
	  function(data){
      		if (data == 'error') {
            	jQuery('#temp_id').remove(); jQuery('#temp_id_dvOverlay').remove();
            }
			jQuery('#PrData').empty();
			jQuery('#PrData').append(data);
	});
}

function submitPromo(pData) {
	//validate
    if (jQuery('#LName').val() == '') {
    	alert('Last name is required.');
        jQuery('#LName')[0].focus();
    	return false;
    }
    if (jQuery('#FName').val() == '') {
    	alert('First name is required.');
        jQuery('#FName')[0].focus();
    	return false;
    }
    if (jQuery('#Email').val() == '') {
    	alert('Email address is required.');
        jQuery('#Email')[0].focus();
    	return false;
    }

	pData = 'id='+pData;
    pData += '&lname='+jQuery('#LName').val();
    pData += '&fname='+jQuery('#FName').val();
    pData += '&email='+jQuery('#Email').val();
    pData += '&mobil='+jQuery('#Mobil').val();
    pData += '&btday='+jQuery('#Btday').val();

	jQuery('#liBtn').hide();
    jQuery('#liBtnWait').show();
	jQuery.post('js.data-exec.php', pData,
	  function(data){
      		if (data != '') {
            	alert(data);
                jQuery('#liBtnWait').hide();
                jQuery('#liBtn').show();
            	return false;
            }
      
			jQuery('#content').empty();
			jQuery('#content').append('<p class="header_copy"><strong>Thank you. Your info has been submitted.</strong></p>');
	});
}

function fnLoc(pId) {
    pTitle = ArrStoreLoc[pId][0];
    pCaption = ArrStoreLoc[pId][1];
    OverlayWindowImg(pId, pTitle, 'fileobj.php?type=13&id='+pId, pCaption);
}

function OverlayWindowImg(pId, pTitle, pImgSrc, pCaption, pPropArr) {
    if (typeof(pId) == 'undefined') { alert('Overlay Window Img Error: pId undefined'); return false; } 
    if (typeof(pTitle) == 'undefined') pTitle = "";
    if (typeof(pImgSrc) == 'undefined') { alert('Overlay Window Img Error: pImgSrc undefined'); return false; } 
    if (typeof(pCaption) == 'undefined') pCaption = ""; 
    else pCaption = "<p>"+pCaption+"</p>"; 
            
    if (typeof(pPropArr) == 'undefined') {
        pPropArr = new Array();
        pPropArr['background-color'] = "#ffffff";
        pPropArr['border-color'] = "#404040";
    } else {
        if (typeof(pPropArr['background-color']) == 'undefined') pPropArr['border-color'] = "#ffffff";
        if (typeof(pPropArr['border-color']) == 'undefined') pPropArr['border-color'] = "#404040";
    }
    
    if (typeof(pHeaderBorderColor) == 'undefined') pHeaderBorderColor = "#8c556f";
    if (typeof(pOverflowY) == 'undefined') pOverflowY = "auto";
    
    jQuery("body").append('<div onclick="jQuery(\'#'+pId+'\').remove(); jQuery(\'#'+pId+'_dvOverlay\').remove();" style="width: 100%; height: 100%; background: #000; position: fixed; top: 0; left: 0; z-index: 98; filter:alpha(opacity=33); -moz-opacity:0.33; opacity: 0.33" id="'+pId+'_dvOverlay"></div>');
    
    var shtml = "";
    shtml += "<div id=\""+pId+"\" style=\"width: auto; height: auto; background-color: "+pPropArr['background-color']+"; border-style: solid; border-color: "+pPropArr['border-color']+"; border-width: 2px; display: none; z-index: 100;\">";
    shtml += "<div id=\""+pId+"_header\" style=\"clear: both; float: left; font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; color: #FFF; background-color: "+pPropArr['border-color']+";\">";
    shtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    shtml += "  <tr>";
    shtml += "    <td>"+pTitle+"</td>";
    shtml += "    <td align=\"right\"><a href=\"javascript: void(0)\" onclick=\"jQuery('#"+pId+"_dvOverlay').remove(); jQuery('#"+pId+"').remove();\"><img src=\"images/overlayClose.gif\" name=\""+pId+"_ImgClose\" width=\"11\" height=\"11\" border=\"0\" id=\""+pId+"_ImgdvPopMsgClose\" /></a></td>";
    shtml += "  </tr>";
    shtml += "</table>";
    shtml += "</div>";
    shtml += "<div id=\""+pId+"_content\" style=\"font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; clear: both; width: auto; color: #000000; background-color: #ffffff; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px;\">";
    shtml += "<div id=\""+pId+"_content_1\" style=\"display:; width: 300px;\"><p align=\"center\" style=\"margin: 10px;\">Loading...</p></div>";
    shtml += "<div id=\""+pId+"_content_2\" style=\"position: absolute; top: -8000px; left: -8000px;\"><img id=\""+pId+"_content_2_img\" src=\""+pImgSrc+"\" border=\"0\">"+pCaption+"</div>";
    shtml += "</div></div>"
    jQuery("body").append(shtml);
   
    jQuery("#"+pId+'_content_2_img').load(
        function () {
            jQuery("#"+pId+'_content_1').hide();
            jQuery("#"+pId+'_content_2').css('visibility','hidden');
            jQuery("#"+pId+'_content_2').css("top", 0);
            jQuery("#"+pId+'_content_2').css("left", 0);
            jQuery("#"+pId+'_content_2').css("position", "relative");
                        
            jQuery("#"+pId+'_content').css('width', jQuery("#"+pId+'_content_2_img').width());
            jQuery("#"+pId+'_header').css('width', jQuery("#"+pId+'_content_2_img').width());
            jQuery("#"+pId).css("top", jQuery(window).scrollTop()+((jQuery(window).height()/2)-(jQuery("#"+pId).height()/2))); 
            jQuery("#"+pId).css("left", jQuery(window).scrollLeft()+((jQuery(window).width()/2)-(jQuery("#"+pId).width()/2)));
        
            if (parseInt(jQuery("#"+pId).css("top")) <= 0) {
                jQuery("#"+pId).css("top", 0);
            }
            if (parseInt(jQuery("#"+pId).css("left")) <= 0) {
                jQuery("#"+pId).css("left", 0);
            }
            jQuery("#"+pId+'_content_2').hide();
            jQuery("#"+pId+'_content_2').css('visibility','');
            jQuery("#"+pId+'_content_2').fadeIn("slow");
        }
    );
    
    
    jQuery("#"+pId+'_dvOverlay').fadeIn("slow", 
        function () {		
            if (jQuery("#"+pId+'_content_2 img')[0].complete) {
                jQuery("#"+pId+'_content_1').hide();
                jQuery("#"+pId+'_content_2').css("top", 0);
                jQuery("#"+pId+'_content_2').css("left", 0);
                jQuery("#"+pId+'_content_2').css("position", "relative");
            }
        
            jQuery("#"+pId).css("position", "absolute");  
            jQuery("#"+pId).fadeIn("slow");
                        
            if (jQuery("#"+pId+'_content_2 img')[0].complete) {
                jQuery("#"+pId+'_content').css('width', jQuery("#"+pId+'_content img').width());
                jQuery("#"+pId+'_header').css('width', jQuery("#"+pId+'_content img').width());
            } else {
            	var tWidth = jQuery("#"+pId+'_content_1').width();
                jQuery("#"+pId+'_content').css('width', tWidth);
                jQuery("#"+pId+'_header').css('width', tWidth);
                /*jQuery("#"+pId+'_content').css('width', jQuery("#"+pId+'_content').width());
                jQuery("#"+pId+'_header').css('width', jQuery("#"+pId+'_content').width());*/
            }
            
            jQuery("#"+pId).css("top", jQuery(window).scrollTop()+((jQuery(window).height()/2)-(jQuery("#"+pId).height()/2))); 
            jQuery("#"+pId).css("left", jQuery(window).scrollLeft()+((jQuery(window).width()/2)-(jQuery("#"+pId).width()/2)));
            jQuery("#"+pId).css("z-index", 100);
            
            if (parseInt(jQuery("#"+pId).css("top")) <= 0) {
                jQuery("#"+pId).css("top", 0);
            }
            if (parseInt(jQuery("#"+pId).css("left")) <= 0) {
                jQuery("#"+pId).css("left", 0);
            }
        }
    );	
}
