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];}
}

/* correct hide/show delay start */
var hide_show_effect_time = (new Date()).getTime();

function showEffect(val){
	var elem = $("#" + val);
	if(elem.css('display') == 'none'){
		if ( (new Date()).getTime() - hide_show_effect_time > 300){
			elem.slideDown('normal');	
		}else{
			elem.show();
		}
	}
	//$("#" + val).fadeIn('slow');
}
function showNormal(val){
	var elem = $("#" + val);
	if(elem.css('display') == 'none'){
		elem.show();
	}
}
function hideNormal(val){
	$("#" + val).hide();
	hide_show_effect_time = (new Date()).getTime();
}

/* correct hide/show delay end */

function fbs_click(u,t){
	if (!u)
		u=location.href;
	if (!t)
		t=document.title;
		if (_gaq)
		{
		   _gaq.push(['_link', 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t)]);return false; 	 
		}
		 else
		 {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
		 }
}

function share(value, u, t) {
	if (!u)
		u=location.href;
	if (!t)
		t=document.title;
	u = encodeURIComponent(u);
	t = encodeURIComponent(t);
	if (value == 'del.icio.us') {
       if (_gaq)  
		_gaq.push(['_link', 'http://del.icio.us/post?url='+u+'&title='+t])
		else
		{
		 window.open('http://del.icio.us/post?url='+u+'&title='+t, 'bookmark','toolbar=0,status=0,width=820,height=520');
	   }
	}
	if (value == 'google') {
		
		if (_gaq)
	       _gaq.push(['_link', 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+u+'&title='+t]);	
		else
		{
		window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk='+u+'&title='+t, 'bookmark', 'toolbar=0,status=0,width=780,height=520');}
	}
	if (value == 'yahoo') {
		if (_gaq)
		   _gaq.push(['_link', 'http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u='+u+'&t='+t]);
		else {   	
		window.open('http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u='+u+'&t='+t, 'bookmark', 'toolbar=0,status=0,width=780,height=520');}
	}
	if (value == 'facebook'){
		if (_gaq)
		   _gaq.push(['_link', 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t)]);
		 else
		 {   
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');}
	}
	return false;
}
function isValidType(flag, oInput, oType ) {
	switch( oType.toLowerCase() ) {
		case 'text':
			if ((!oInput.value) && (!flag))
			{
				oInput.focus();
			}
			return oInput.value;
		case 'select':
			if (!oInput.selectedIndex && !flag)
			{
				oInput.focus();
			}
			return oInput.selectedIndex;
		case 'photo':
			if(oInput.value == "" || oInput.value == null) {
					//oInput.focus();
					//return false;
				} else {
					validformFile = /(.jpg|.gif|.png)$/;			
					if(!validformFile.test(oInput.value.toLowerCase())){
						//alert("Only JPG/GIF/PNG files are supported. Please try again");
						if (!flag){
							oInput.focus();
							oInput.select();
						}
						return false;
					}
				}
			 return true;
		case 'email':
			if ( oInput.value && !oInput.value.replace( /[\w\-\+]+(\.[\w\-\+]+)*@([\w\-áàäçéèêñóòôöüæøå]+\.)+[a-z]+/i, "" ) )
			{ return true; }
			else {
				if (!flag)
					oInput.focus();
				return false;
			}
		case 'radio':
			for (var i=0; i < oInput.length; i++){
				if (oInput[i].checked){ break; }
			}
			if (i == oInput.length) { 
				if (!flag){
					oInput[0].focus();
					oInput[0].select();
				}
				return false; 
			}
			else { return true; }
		case 'number':
			if( !oInput.value ) { return false; }
			else {
				for( var mXi = 0; mXi < oInput.value.length; mXi++ ) {
					if( oInput.value.charAt( mXi ) != '' + parseInt( oInput.value.charAt( mXi ) ) + '' )
					{ 
						if (!flag)
							oInput.focus();
						return false; 
					}
				}
				return true;
			}
	}
}
