
function Browser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if (navigator.userAgent.indexOf("Opera")>0) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns5=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6')>0);
	this.ie7=(this.version.indexOf('MSIE 7')>0);	
	this.ie8=(this.version.indexOf('MSIE 8')>0);	
	this.opera=(this.b=="opera");
	this.dom=((document.createRange&&(document.createRange().createContextualFragment)||this.ie5||this.ie55||this.ie6||this.ie7||this.ie8)?true:false);
	this.flash=false;
	if(this.ie){
		this.flash=((navigator.appName == "Microsoft Internet Explorer") && (navigator.appVersion.indexOf("Mac") == -1) && (navigator.appVersion.indexOf("3.1") == -1));
	}
	if(this.ns){
		this.flash=(navigator.plugins && navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"]);
	}
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}

var is=new Browser();

function getObj(id){
	var obj;
	if(is.ie4)obj=document.all[id];
	if(is.ns4)obj=document[id];
	if(is.dom||is.ie5){
		obj=document.getElementById(id);
	}
	return obj;
}

function getStyleObj(id){
	var obj;
	if(is.ie4)obj=document.all[id].style;
	if(is.ns4)obj=document[id];
	if(is.dom)obj=document.getElementById(id).style;
	return obj;
}

function moveObj(div,x,y){
	var obj=getStyleObj(div);
	obj.left=x;
	obj.top=y;
}

function showObj(div){
	var obj=getStyleObj(div);
	obj.visibility='visible';
}

function hideObj(div){
	var obj=getStyleObj(div);
	obj.visibility='hidden';
}

function writeObj(div, text){
	var obj=getObj(div);
	if(is.ie4||is.ie5||is.dom)obj.innerHTML=text;
	if(is.ns4){
		obj.document.write(text)
		obj.document.close();
	}
}

function getObjX(div){
	return parseInt(getStyleObj(div).left);
}

function getObjY(div){
	return parseInt(getStyleObj(div).top);
}

function changeImg(id, newImage){
	var imgObj=getObj(id);
	if(typeof(imgObj)=='object'){
		imgObj.src=newImage;
	}
}

function changeBgColor(id, color)
{
	var obj=getStyleObj(id);
	if(typeof(obj)=='object'){
		obj.backgroundColor=color;
	}	
}

var sText;

function uploading(){
	sText='Uploading . . . ';
	showObj('uploadingDiv');
	writeObj('uploadingDiv', sText);
	setInterval('writeDots()',2500)
}

function writeDots(){
	sText+='. ';
	writeObj('uploadingDiv', sText);
}


/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 2;
		yOffset = 2;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */

	$(".preview").hover(function(e){
		this.t = this.title;
		if (this.t) this.title = "";	
    
		this.imgurl = this.name;
		this.imgurl = this.imgurl.replace(/_/g,"/");

		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		$("body").append("<p id='preview'><img src='"+ this.imgurl +"' alt='Image preview' />"+ c +"</p>");								 
		

    	var posY;

        if (e.pageY - $(window).scrollTop() + $('#preview').height() >= $(window).height() ) {
        posY = $(window).height() + $(window).scrollTop() - $('#preview').height() - 15 ;
        } else {
        posY = e.pageY + yOffset;
        }
        $("#preview")
        .css("top",(posY) + "px")
        .css("left",(e.pageX + xOffset) + "px")
        .fadeIn("fast");	    				
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$(".preview").mousemove(function(e){
	
    	var posY;

        if (e.pageY - $(window).scrollTop() + $('#preview').height() >= $(window).height() ) {
        posY = $(window).height() + $(window).scrollTop() - $('#preview').height() - 15 ;
        } else {
        posY = e.pageY + yOffset;
        }
        $("#preview")
        .css("top",(posY) + "px")
        .css("left",(e.pageX + yOffset) + "px");

	});			

};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});