var tb_pathToImage="http://www.devicecode.net/pc/img/bar.gif";
$(document).ready(function(){
tb_init('a.thickbox, area.thickbox, input.thickbox');
imgLoader=new Image();
imgLoader.src=tb_pathToImage;
});
function tb_init(domChunk){
$(domChunk).click(function(){
var t=this.title||this.name||null;
var a=this.href||this.alt;
var g=this.rel||false;
tb_show(t,a,g);
this.blur();
return false;
});
}
function tb_show(caption,url,imageGroup){
try{
if(typeof document.body.style.maxHeight==="undefined"){
$("body","html").css({height:"100%",width:"100%"});
$("html").css("overflow","hidden");
if(document.getElementById("tb_HideSelect")===null){
$("body").append("<iframe id='tb_HideSelect'></iframe><div id='tb_overlay'></div><div id='tb_window'></div>");
$("#tb_overlay").click(tb_remove);
}
}else{
if(document.getElementById("tb_overlay")===null){
$("body").append("<div id='tb_overlay'></div><div id='tb_window'>");
$("#tb_overlay").click(tb_remove);
}
}
if(caption===null){caption="";}
$("body").append("<div id='tb_load'><img src='"+imgLoader.src+"' /></div>");
$('#tb_load').show();
var baseURL;
if(url.indexOf("?")!==-1){
baseURL=url.substr(0,url.indexOf("?"));
}else{
baseURL=url;
}
var urlString=/\.jpg|\.jpeg|\.png|\.gif|\.bmp/g;
var urlType=baseURL.toLowerCase().match(urlString);
if(urlType=='.jpg'||urlType=='.jpeg'||urlType=='.png'||urlType=='.gif'||urlType=='.bmp'){
tb_PrevCaption="";
tb_PrevURL="";
tb_PrevHTML="";
tb_NextCaption="";
tb_NextURL="";
tb_NextHTML="";
tb_imageCount="";
tb_FoundURL=false;
if(imageGroup){
tb_TempArray=$("a[@rel="+imageGroup+"]").get();
for(tb_Counter=0;((tb_Counter<tb_TempArray.length)&&(tb_NextHTML===""));tb_Counter++){
var urlTypeTemp=tb_TempArray[tb_Counter].href.toLowerCase().match(urlString);
if(!(tb_TempArray[tb_Counter].href==url)){
if(tb_FoundURL){
tb_NextCaption=tb_TempArray[tb_Counter].title;
tb_NextURL=tb_TempArray[tb_Counter].href;
tb_NextHTML="<span id='tb_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
}else{
tb_PrevCaption=tb_TempArray[tb_Counter].title;
tb_PrevURL=tb_TempArray[tb_Counter].href;
tb_PrevHTML="<span id='tb_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
}
}else{
tb_FoundURL=true;
tb_imageCount="Image "+(tb_Counter+1)+" of "+(tb_TempArray.length);
}
}
}
imgPreloader=new Image();
imgPreloader.onload=function(){
imgPreloader.onload=null;
var pagesize=tb_getPageSize();
var x=pagesize[0]-150;
var y=pagesize[1]-150;
var imageWidth=imgPreloader.width;
var imageHeight=imgPreloader.height;
if(imageWidth>x){
imageHeight=imageHeight*(x/imageWidth);
imageWidth=x;
if(imageHeight>y){
imageWidth=imageWidth*(y/imageHeight);
imageHeight=y;
}
}else if(imageHeight>y){
imageWidth=imageWidth*(y/imageHeight);
imageHeight=y;
if(imageWidth>x){
imageHeight=imageHeight*(x/imageWidth);
imageWidth=x;
}
}
tb_WIDTH=imageWidth+30;
tb_HEIGHT=imageHeight+60;
$("#tb_window").append("<a href='' id='tb_ImageOff' title='Close'><img id='tb_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>"+"<div id='tb_caption'>"+caption+"<div id='tb_secondLine'>"+tb_imageCount+tb_PrevHTML+tb_NextHTML+"</div></div><div id='tb_closeWindow'><a href='#' id='tb_closeWindowButton' title='Close'>close</a> or Esc Key</div>");
$("#tb_closeWindowButton").click(tb_remove);
if(!(tb_PrevHTML==="")){
function goPrev(){
if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
$("#tb_window").remove();
$("body").append("<div id='tb_window'></div>");
tb_show(tb_PrevCaption,tb_PrevURL,imageGroup);
return false;
}
$("#tb_prev").click(goPrev);
}
if(!(tb_NextHTML==="")){
function goNext(){
$("#tb_window").remove();
$("body").append("<div id='tb_window'></div>");
tb_show(tb_NextCaption,tb_NextURL,imageGroup);
return false;
}
$("#tb_next").click(goNext);
}
document.onkeydown=function(e){
if(e==null){
keycode=event.keyCode;
}else{
keycode=e.which;
}
if(keycode==27){
tb_remove();
}else if(keycode==190){
if(!(tb_NextHTML=="")){
document.onkeydown="";
goNext();
}
}else if(keycode==188){
if(!(tb_PrevHTML=="")){
document.onkeydown="";
goPrev();
}
}
};
tb_position();
$("#tb_load").remove();
$("#tb_ImageOff").click(tb_remove);
$("#tb_window").css({display:"block"});
};
imgPreloader.src=url;
}else{
var queryString=url.replace(/^[^\?]+\??/,'');
var params=tb_parseQuery(queryString);
tb_WIDTH=(params['width']*1)+30||630;
tb_HEIGHT=(params['height']*1)+40||440;
ajaxcontentW=tb_WIDTH-30;
ajaxcontentH=tb_HEIGHT-45;
if(url.indexOf('tb_iframe')!=-1){
urlNoQuery=url.split('tb_');
$("#tb_window").append("<div id='tb_title'><div id='tb_ajaxWindowTitle'>"+caption+"</div><div id='tb_closeAjaxWindow'><a href='#' id='tb_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='tb_iframeContent' name='tb_iframeContent' style='width:"+(ajaxcontentW+29)+"px;height:"+(ajaxcontentH+17)+"px;' onload='tb_showIframe()'> </iframe>");
}else{
if($("#tb_window").css("display")!="block"){
if(params['modal']!="true"){
$("#tb_window").append("<div id='tb_title'><div id='tb_ajaxWindowTitle'>"+caption+"</div><div id='tb_closeAjaxWindow'><a href='#' id='tb_closeWindowButton'>close</a> or Esc Key</div></div><div id='tb_ajaxcontent' style='width:"+ajaxcontentW+"px;height:"+ajaxcontentH+"px'></div>");
}else{
$("#tb_overlay").unbind();
$("#tb_window").append("<div id='tb_ajaxcontent' class='tb_modal' style='width:"+ajaxcontentW+"px;height:"+ajaxcontentH+"px;'></div>");
}
}else{
$("#tb_ajaxcontent")[0].style.width=ajaxcontentW+"px";
$("#tb_ajaxcontent")[0].style.height=ajaxcontentH+"px";
$("#tb_ajaxcontent")[0].scrollTop=0;
$("#tb_ajaxWindowTitle").html(caption);
}
}
$("#tb_closeWindowButton").click(tb_remove);
if(url.indexOf('tb_inline')!=-1){
$("#tb_ajaxcontent").html($('#'+params['inlineId']).html());
tb_position();
$("#tb_load").remove();
$("#tb_window").css({display:"block"});
}else if(url.indexOf('tb_iframe')!=-1){
tb_position();
if(frames['tb_iframeContent']===undefined){
$("#tb_load").remove();
$("#tb_window").css({display:"block"});
$(document).keyup(function(e){var key=e.keyCode;if(key==27){tb_remove();}});
}
}else{
$("#tb_ajaxcontent").load(url+="&random="+(new Date().getTime()),function(){
tb_position();
$("#tb_load").remove();
tb_init("#tb_ajaxcontent a.thickbox");
$("#tb_window").css({display:"block"});
});
}
}
if(!params['modal']){
document.onkeyup=function(e){
if(e==null){
keycode=event.keyCode;
}else{
keycode=e.which;
}
if(keycode==27){
tb_remove();
}
};
}
}catch(e){
}
if (document.getElementsByName('key_private_password')[2]) {
document.getElementsByName('key_private_password')[2].focus();
}
}
function tb_showIframe(){
$("#tb_load").remove();
$("#tb_window").css({display:"block"});
}
function tb_remove(){
$("#tb_imageOff").unbind("click");
$("#tb_overlay").unbind("click");
$("#tb_closeWindowButton").unbind("click");
$("#tb_window").fadeOut("fast",function(){$('#tb_window,#tb_overlay,#tb_HideSelect').remove();});
$("#tb_load").remove();
if(typeof document.body.style.maxHeight=="undefined"){
$("body","html").css({height:"auto",width:"auto"});
$("html").css("overflow","");
}
document.onkeydown="";
return false;
}
function tb_position(){
$("#tb_window").css({marginLeft:'-'+parseInt((tb_WIDTH/2),10)+'px',width:tb_WIDTH+'px'});
if(!(jQuery.browser.msie&&typeof XMLHttpRequest=='function')){
$("#tb_window").css({marginTop:'-'+parseInt((tb_HEIGHT/2),10)+'px'});
}
}
function tb_parseQuery(query){
var Params={};
if(!query){return Params;}
var Pairs=query.split(/[;&]/);
for(var i=0;i<Pairs.length;i++){
var KeyVal=Pairs[i].split('=');
if(!KeyVal||KeyVal.length!=2){continue;}
var key=unescape(KeyVal[0]);
var val=unescape(KeyVal[1]);
val=val.replace(/\+/g,' ');
Params[key]=val;
}
return Params;
}
function tb_getPageSize(){
var de=document.documentElement;
var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
arrayPageSize=[w,h];
return arrayPageSize;
}