// $Id: common.js,v 1.1.1.1.2.11 2007/11/30 14:08:00 lukian Exp $

var __isIE		= document.all			? true : false;
var __isDOM	= document.getElementById	? true : false;
var __isNS4	= document.layers		? true : false;

function glob_getBlock(b){
	if ( __isDOM )	return document.getElementById(b);
	if ( __isIE )		return document.all.b;
	if ( __isNS4 )	return document.layers[b];
}

function firstLoadExec(){
	return ;
	if ( cGet( 'elidoLoaded' ) == 1 ) {
		glob_getBlock( 'logoImageId' ).style.display = 'block';
		glob_getBlock( 'tufImageId' ).style.display = 'block';
		return true;
	}
	new Effect.Grow( 'logoImageId' );
	new Effect.Grow( 'tufImageId' );
	cSet( 'elidoLoaded', 1, 1 );
}

function cGet(cName) {
	if ( document.cookie.length > 0 ) {
		var begin = document.cookie.indexOf( cName + "=" );
		var end;
		if ( begin != -1 ) {
			begin += cName.length + 1;
			end    = document.cookie.indexOf( ";", begin );
			if ( end == -1 ) end = document.cookie.length;
			return unescape( document.cookie.substring( begin, end ) );
		}
	}
	return '';
}

function cSet (cName,cValue,cExp ){
	document.cookie = cName + "=" + escape( cValue ) + ';path=/;';
}

function mouseOverLink(obj){
	try{obj.style.cursor = 'pointer';}catch(e){}
}

function mouseOutLink(obj){
	try{obj.style.cursor = 'normal';}catch(e){}
}

function largeView_setImage(targetImgId,newImage,sold){
	try{
		if ( sold == 1 ) {
			glob_getBlock( targetImgId ).style.backgroundImage = 'url( /pimages/' + newImage + ' )';
		} else {
			glob_getBlock( targetImgId ).src = '/pimages/' + newImage;
		}
	} catch(e){}
}

var __GLOB_GALLERY_IMAGES__;
function gal_getImages(){
	return __GLOB_GALLERY_IMAGES__;
}

function gal_initGallery(imgs){
	if ( typeof( imgs ) != 'object' ) {
		return;
	}
	__GLOB_GALLERY_IMAGES__ = imgs;
	var oNw = window.open( '/html/gallery.html','galPopup','width=635,height=700');
	if ( ! oNw ) {
		if ( lang == 'bg' ) {
			alert( 'Моля позволете отварянето на нови прозорци от вашия браузър' );
		} else {
			alert( 'You have a pop up blocker. Please allow the pop ups for this site.' );
		}
	}
	try {oNw.focus();}catch(e){}
}

function gal_showImage(_src,_target){
	glob_getBlock( _target ).src = '/pimages/' + _src;
	return false;
}

function mail_setStatus(stat,id){
	try {
		if ( stat == 'error' ) {
			glob_getBlock( id + '_mailStatSuccessId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatLoadingId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatErrorId' ).style.display = 'block';
		} else if ( stat == 'success' ) {
			glob_getBlock( id + '_mailStatErrorId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatLoadingId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatSuccessId' ).style.display = 'block';
			setTimeout( 'slidedown_showHide( "' + id + '_box2");', 2000 );
		} else {
			glob_getBlock( id + '_mailStatErrorId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatLoadingId' ).style.display = 'none';
			glob_getBlock( id + '_mailStatSuccessId' ).style.display = 'none';
		}
	} catch(e){}
}

function checkTellAFriendData(id){

//	if ( glob_getBlock( id + '_friendSender' ).value == '' || ! glob_getBlock( id + '_friendSender' ).value ) {
//		if ( lang == 'bg' ) {
//			alert( 'Моля попълнете полето: "Е-mail на получателя"' );
//			return false;
//		}
//	}

	glob_getBlock( id + '_mailStatLoadingId' ).style.display = 'block';
	glob_getBlock( id + '_mailStatErrorId' ).style.display = 'none';
	glob_getBlock( id + '_mailStatSuccessId' ).style.display = 'none';
	return true;
}

function glob_removeSelectOptions(id){
	if ( glob_getBlock( id ).options.length > 0 ) {
		glob_getBlock( id ).options[0] = null;
		glob_removeSelectOptions( id );
	}
}
