<!--

///////////////////////////////////////////////////////\\
///////////////////////////////////////////////////////\\
//***************************************************\\\\
//              JQuery Float Dialog v2.0             \\\\
//                    Easy PopUp                     \\\\
//                    ExpBuilder                     \\\\
//                elkadrey@gmail.com                 \\\\
//              Auther: Ahmed Elkadrey               \\\\
//***************************************************\\\\
///////////////////////////////////////////////////////\\
///////////////////////////////////////////////////////\\
jQuery.fn.floatdialog = function(id, options)
{
   var Config = {
                     backgroundcolor: "#000000",
                     speed          : 'slow',
                     event          : 'click',
                     effect         : true,
                     move           : 'default',
                     closeClass     : '.closebutton',
                     sound          : false,
                     soundsrc       : 'audio/sound01.mp3'
                };
    if(options)
    {
		jQuery.extend(Config, options);
	};
    //functions
    //{
    function brwstester()
    {
        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
    }
    function resizeheights(me)
    {
        $("#" + me).css({'height' : $(window).height() + brwstester().scrollTop  + "px"});
    }
    function display_mask(id)
    {
        if(Config.effect)
        {
            $("#floatdialog_mask_" + id).show().fadeTo(Config.speed, 0.33);
        }
        else
        {
            $("#floatdialog_mask_" + id).css({opacity: '0.33'}).show();
        }
    }
    function center_form(id)
    {
          var scwidth  = screen.width;
          var scheight = screen.height;
          var tblwidth = $("#" + id).width();
          var tblheight = $("#" + id).height();
          var D_width = (scwidth - tblwidth);
          if(D_width > 0)
          {
              D_width /= 2;
          }
          else if(D_width < 0)
          {
              D_width *= -1;
              D_width /= 2;
          }
          $("#" + id).css('left', D_width  + 'px');
          var D_height = (scheight - tblheight);
          if(D_height > 0)
          {
              D_height /= 2;
          }
          else if(D_height < 0)
          {
              D_height *= -1;
              D_height /= 2;
          }
          $("#" + id).css('top', brwstester().scrollTop + D_height /2 + 'px');
    }
    function display_form(id)
    {
        display_mask(id);
        center_form(id);
        $(window).scroll(function()
        {
            center_form(id);
        });
        if(Config.sound == true && Config.soundsrc)
        {
             $('#expbuilder_flash_floatdialog_' + id).remove();
             $("body").append('<div style="width: 0px;height: 0px;display: inline;" id="expbuilder_flash_floatdialog_' + id + '"><object id="expbuilder_flash_floatdialog_' + id + '_flash" height="0" width="0" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">  <param value="vid" name="id"/><param value="middle" name="align"/>  <param value="sameDomain" name="allowScriptAccess"/>  <param value="true" name="allowFullScreen"/>  <param value="high" name="quality"/>  <param value="expbuilder-soundplayer.swf?' + Config.soundsrc + '" name="src"/>  <embed src="expbuilder-soundplayer.swf?' + Config.soundsrc + '" height="0" width="0" allowscriptaccess="sameDomain" allowfullscreen="true" quality="high" bgcolor="#000000" type="application/x-shockwave-flash" id="vid"/></object></div>');
             //document.getElementById('expbuilder_flash_floatdialog_' + id).setVariable( "soundurl", Config.soundsrc);
        }
        if(Config.move == 'down')
        {
            //move from up
            var top = document.getElementById(id).style.top;
            $("#" + id).css({'top': (brwstester().scrollTop - 100) + 'px'}).show().animate({"top":  top}, Config.speed);
        }
        else if(Config.move == 'up')
        {
            //move from down
            var top = document.getElementById(id).style.top;
            $("#" + id).css({'top': (brwstester().scrollTop +  (screen.height)) + 'px'}).show().animate({"top": top}, Config.speed);
        }
        else if(Config.move == 'right')
        {
            //move from left
            var left = document.getElementById(id).style.left;
            $("#" + id).css({'width': $("#" + id).width(), 'left': screen.width + 'px'}).show().animate({"left": left}, Config.speed);
        }
        else if(Config.move == 'left')
        {
            //move from right
            var left = document.getElementById(id).style.left;
            $("#" + id).css({'width': $("#" + id).width(), 'left': '-' + $("#" + id).width() + 'px'}).show().animate({"left": left}, Config.speed);
        }
        else if(Config.move == 'slidedown')
        {
            $("#" + id).slideDown(Config.speed);
        }
        else
        {
            //default
            if(Config.effect)
            {
                $("#" + id).fadeIn(Config.speed);
            }
            else
            {
                $("#" + id).show();
            }
        }
    }
    function disable_mask(id)
    {
        $(".disable_masking").hide();
        if(Config.effect)
        {
            $("#floatdialog_mask_" + id).fadeOut(Config.speed).fadeTo("", 100);
        }
        else
        {
            $("#floatdialog_mask_" + id).hide();
        }
    }
    //}
    $(document).ready(function()
    {
        if(!$("#floatdialog_mask_" + id).html())
        {
             $("body").append('<div id="floatdialog_mask_' + id + '" style="display: none;left: 0px;top: 0px;z-index: 6000;position: absolute;background-color:' + Config.backgroundcolor + '">&nbsp;</div>');
             $("#floatdialog_mask_" + id).css({'width' : screen.availWidth  + "px"}).bind('click', function()
             {
                 disable_mask(id);
             });
             resizeheights('floatdialog_mask_' + id);
             if(Config.closeClass)
             {
                 $(Config.closeClass).bind('click', function()
                 {
                     disable_mask(id);
                 });
             }
        }
    });
    $("#" + id).hide().addClass('disable_masking');
    $(window).scroll(function()
     {
         resizeheights('floatdialog_mask_' + id);
     });

     if(Config.event == "load")
     {
         $(document).ready(function()
         {
            display_form(id);
         });
     }
     else
     {
        $(this).bind(Config.event, function()
        {
             display_form(id);
        });
     }
}

///////////////////////////////////////////////////

if(top.location != location){
	top.location.href = document.location.href;
}

// D.C.
function popWindow(url, width, height) {
	var Win = window.open(url,"popWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,menubar=no,status=no' );
}

function toggle_visibility(id) {
	// <p><a href="#" onclick="toggle_visibility('cToggle01'); return false;">toggle #cToggle01</a></p>
	// <div id="cToggle01" style="display:none">This is cToggle01</div>
    var e = document.getElementById(id);
    if(e.style.display == 'block'){
        e.style.display = 'none';
    }else{
        e.style.display = 'block';
    }
}

function popupSlideShow(url) {
	// slide show popup: /public_html/ss.php
  window.open(url,'popupSlideShow','width=640,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes')
}

function openWin(theURL,winName,features) {
  w=window.open(theURL,winName,features);
  w.focus();
}

function openWinHelp(URL){
	// User registration Help via popup.php
   open(URL,"_blank","left=150,top=150,width=640,height=480,scrollbars=yes,resizable=yes");
}

// FAQ page id 41; expands answers; see also /style/faq.js.css (#item0, #item1, ...)
var current_item = "item0";
function show_item(item_name)
{
	document.getElementById(current_item).style.display = "none";
	document.getElementById(item_name).style.display = "block";
	current_item = item_name;
}

// 2008/08/05 13:54
// Begin Contact Us form attachments
// Read all notes found at http://www.petefreitag.com/item/587.cfm
var upload_number = 1;
function addFileInput() {
	if(upload_number > 3){
		alert('Sorry, you can only upload 3 files'); // See also $opts['feedback_upld_max']
		exit(0);
	}
	var d = document.createElement("div");
	var l = document.createElement("a"); //***
	var file = document.createElement("input");
	file.setAttribute("type", "file");
	file.setAttribute("size", "50");
	file.setAttribute("style", "margin:5px 10px 5px 0px");
	file.setAttribute("name", "attachment"+upload_number);
	l.setAttribute("href", "javascript:removeFileInput('f"+upload_number+"');");  //***
	l.appendChild(document.createTextNode("Remove"));  //***
	d.setAttribute("id", "f"+upload_number); //***
	d.appendChild(file);
	d.appendChild(l); //***
	document.getElementById("moreUploads").appendChild(d);
	upload_number++;
}
function removeFileInput(i){
	var elm = document.getElementById(i);
	document.getElementById("moreUploads").removeChild(elm);
	upload_number = upload_number - 1;
	// decrement the max file upload counter if the file is removed
}

// End Contact Us form attachments

// Begin TEXTAREA counter used in Lightbox image upload
function TrackCount(fieldObj,countFieldName,maxChars) {
	// Usage: <textarea name="c" rows="6" cols="48" onkeyup="TrackCount(this,'textcount',255)" onkeypress="LimitText(this,255)" onChange="javascript:this.value=this.value.toUpperCase();"></textarea>
	// Characters remaining: <input type="text" name="textcount" size="3" value="255">
	// <br><input type="submit" name="submit1" value="Proceed To The Next Page...">
	var countField = eval("fieldObj.form."+countFieldName);
	var diff = maxChars - fieldObj.value.length;
	// Need to check & enforce limit here also in case user pastes data
	if (diff < 0) {
		fieldObj.value = fieldObj.value.substring(0,maxChars);
		diff = maxChars - fieldObj.value.length;
	}
	countField.value = diff;
}
function LimitText(fieldObj,maxChars) {
	var result = true;
	if (fieldObj.value.length >= maxChars)
		result = false;
	if (window.event)
		window.event.returnValue = result;
	return result;
}
// End TEXTAREA counter used in Lightbox image upload

//-->



