var confirmMsg  = 'Are you sure you want to delete ';
var profile_window = '';
var form_window = '';
var image_window = '';
var WinTop=screen.height/2;
var WinLeft=screen.width/2;
var url = 'http://www.images-team.ro/index.php';
var title = 'Images-Team';

function addBookmark() {
	if (window.sidebar) window.sidebar.addPanel(title, url, ""); 
	else if(document.all) window.external.AddFavorite(url, title); 
	else if( window.opera && window.print ) alert("Sorry! Your browser doesn't support this function."); 
 } 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
 }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
 }

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
 }

function ChangeinnerHTML(layerid, htmlcode) {
    var statement = '';
    if(document.all) statement += "document.all['" + layerid + "'].innerHTML = '" + htmlcode + "';";	     
    else if(document.getElementById) statement += "document.getElementById('" + layerid + "').innerHTML = '" + htmlcode + "';"; 
	eval(statement);
 }

function switch_display(title, image_file, info_body) {
	if(title != '') ChangeinnerHTML('title', title);
	if(image_file != '') ChangeinnerHTML('big', '<img src=include/phpThumb/phpThumb.php?src='+image_file+'&w=496&q=80 border=0>');
	if(info_body != '') ChangeinnerHTML('info', info_body);
 }

function login_box_verif() {
	valid_login = 1;
	if(document.login.username.value=="") {
		alert('Enter your username!');
		document.login.username.focus();
		valid_login = 0;
		return;
	 }	
	if(document.login.password.value=="") {
		alert('Enter the password!');
		document.login.password.focus();
		valid_login = 0;
		return;
	 }
	if( valid_login == 1 ) document.login.submit();
 }

function search_box_verif()
 {
	valid_search = 1;
	if 	(document.search.query.value=="") {
		alert('Enter your query!');
		document.search.query.focus();
		valid_search = 0;
		return;
	 }	
	if(valid_search==1) document.search.submit();
 }

function pause(ms) {
	var now = new Date();
	var exitTime = now.getTime() + ms;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime) return;
	 }
 }

function popUp(URL) {
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=480,height=640,left = 400,top = 192');");
 }

function confirmLink(theLink, theMessage) {
    //if (confirmMsg == '' || typeof(window.opera) != 'undefined') return true;
    var is_confirmed = confirm(confirmMsg + theMessage);
    if (is_confirmed) theLink.href += '&confirmed=1';
    return is_confirmed;
 }

function open_profile_window(url,w,h) {
	day = new Date();
	id = day.getTime();
	if (!w || !h) {
		w = 500;
		h = 400;
	 }
    if (!profile_window.closed && profile_window.location) {
        profile_window.focus();
		profile_window.location = url;
     }
	else {
		features = 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+w+',height='+h+',top='+(WinTop-h/2)+",left="+(WinLeft-w/2);
        profile_window = window.open(url, id, features);
		profile_window.opener = self;
	 }
    if (window.focus) profile_window.focus();
    return false;
 }

function open_image_window(url,w,h) {
	day = new Date();
	id = day.getTime();
	if (!w || !h) {
		w = 500;
		h = 400;
	 }
    if (!image_window.closed && image_window.location) image_window.close();
	features = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+w+',height='+h+',top='+(WinTop-h/2)+",left="+(WinLeft-w/2);
	image_window = window.open(url, id, features);
	image_window.opener = self;
    if (!image_window.opener) image_window.opener = self;
    if (window.focus) image_window.focus();
    return false;
 }

function open_form_window(url,w,h) {
	day = new Date();
	id = day.getTime();
	if (!w || !h) {
		w = 500;
		h = 400;
	 }
    if (!form_window.closed && form_window.location) {
        form_window.focus();
		form_window.location = url;
     }
	else {
		features = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+w+',height='+h+',top='+(WinTop-h/2)+",left="+(WinLeft-w/2);
        form_window = window.open(url, id, features);
		form_window.opener = self;
     }
    if (!form_window.opener) form_window.opener = self;
    if (window.focus) form_window.focus();
    return false;
 }
