// -------------------------------------------------------------------

// Image Thumbnail Viewer Script- By Dynamic Drive, available at: http://www.dynamicdrive.com

// Last updated: July 7th, 2008- Fixed enlarged image not showing in IE sometimes

// -------------------------------------------------------------------



var newsbox={
enableTitle: true, //Should "title" attribute of link be used as description?
enableAnimation: true, //Enable fading animation?
definefooter: '<div class="footerbar" onClick="newsbox.closeit()" style="background: url('+websiteURL+'images/news.pop.header.jpg) no-repeat;">X</div>', //Define HTML for footer interface
defineLoading: '<div align="center"><img src="'+websiteURL+'images/loading.gif" width="220" /><br /> Se incarca...</div>', //Define HTML for "loading" div

/////////////No need to edit beyond here/////////////////////////

scrollbarwidth: 16,

createloginBox:function(){
//write out HTML for Image Thumbnail Viewer plus loading div
newsHTML = '\
<div align="center" style="height:250px; background: url(' + websiteURL + 'images/news.pop.text.jpg) no-repeat;">\
    <div style="padding-top: 100px;" class="pop_form">\
        <form method="post" action="' + websiteURL + 'voucher" name="voucher_1" onsubmit="return validate_form(\'voucher\',\'1\');">\
        <input type="hidden" name="is_popup" value="1" />\
        <table width="287" border="0" cellspacing="0" class="padding_4">\
        <tr>\
            <td colspan="2" style="padding: 0;"><div style="font-weight: normal;" class="error text_11" id="voucher_1_err"><br /></div></td>\
        </tr>\
        <tr>\
            <td align="left"><label for="voucher_prenume_1" id="label_voucher_prenume_1">Prenume</label></td>\
            <td align="left"><input id="voucher_prenume_1" name="voucher_prenume_1" type="text" size="30" /></td>\
        </tr>\
        <tr>\
            <td align="left"><label for="voucher_email_1" id="label_voucher_email_1">E-mail</label></td>\
            <td align="left"><input id="voucher_email_1" name="voucher_email_1" type="text" size="30" /></td>\
        </tr>\
        <tr>\
            <td colspan="2" align="center" valign="bottom" style="padding-top: 20px;"><input id="voucher_1_submit" class="voucher_submit hand" type="submit" value="DA! vreau un voucher de 20 ron GRATUIT" /></td>\
        </tr>\
        </table>\
        </form>\
    </div>\
</div>';

document.write('<div id="newsForm">'+this.definefooter+newsHTML+'</div>')
document.write('<div id="newsLoading">'+this.defineLoading+'</div>')
this.loginBox=document.getElementById("newsForm")
this.loginLoading=document.getElementById("newsLoading") //Reference "loading" div that will be shown while image is fetched
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
},

centerDiv:function(divobj){ //Centers a div element on the page
var ie=document.all && !window.opera
var dom=document.getElementById
var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
var objwidth=divobj.offsetWidth //width of div element
var objheight=divobj.offsetHeight //height of div element
var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
divobj.style.top=Math.floor(parseInt(topposition))+"px"
divobj.style.visibility="visible"
},

showloginBox:function(){ //Show ThumbBox div
newsbox.loginLoading.style.visibility="hidden" //Hide "loading" div
this.centerDiv(this.loginBox)
//document.getElementById('login_user2').focus();
},

loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
if (this.loginBox.style.visibility=="visible") //if thumbox is visible on the page already
this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
this.centerDiv(this.loginLoading) //Center and display "loading" div while we set up the image to be shown
setTimeout("newsbox.showloginBox()",1000);
},

closeit:function(){ //Close "thumbbox" div function
this.loginBox.style.visibility="hidden"
this.loginBox.style.left="-2000px"
this.loginBox.style.top="-2000px"
//document.getElementById("newsWrapper").style.display = "none";
},
cleanup:function(){ //Clean up routine on page unload
this.loginLoading=null
this.loginBox=null
},

dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}
}

newsbox.createloginBox() //Output HTML for the image thumbnail viewer
newsbox.dotask(window, function(){newsbox.cleanup()}, "unload")
