function NewWin(newURL,wth,hgh)
{
	window.open(newURL,'','width='+wth+',height='+hgh+',left=0,top=0,scrollbars=yes');
}

function isIE() {
	if (navigator.appName!="Microsoft Internet Explorer") {
		return false;
	}
	return true;
}

function correctPNG() 
{
   for(var i=0; i<document.images.length; i++) {
	  var img = document.images[i];
	  var LW = img.width;
	  var LH = img.height;
	  var imgName = img.src.toUpperCase();
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { 
		 img.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+img.src+", sizingmethod=scale);" ;
		 img.src = "images/space.gif";
		 img.width = LW;
		 img.height = LH;
	  }
   }
}

function hidebar()
{
	document.getElementById('tools_search_input').style.display = 'none'; 
	document.getElementById('tools_search').style.display = 'block';
}

function showbar()
{
	document.getElementById('tools_search').style.display='none'; 
	document.getElementById('tools_search_input').style.display='block';
	document.getElementById('input_search').focus();
	document.getElementById('input_search').select();
}

function pageRedirect(page)
{
	window.location=page;
}

function showFavorite() {
	var favoriteWindow = document.getElementById('favoritelist');
	if (favoriteWindow.style.display=='block') {
		favoriteWindow.style.display='none';
	}
	else {
		if(document.getElementById('templatelist') != null) {
			hideTemplate();
		}
		favoriteWindow.style.display='block';
	}
}

function hideFavorite() {
	var favoriteWindow = document.getElementById('favoritelist');
	favoriteWindow.style.display = 'none';
}

function showTemplateList() {
	var templateWindow = document.getElementById('templatelist');
	
	if (templateWindow.style.visibility == 'visible') {
		//templateWindow.style.display='none';
		templateWindow.style.visibility = 'hidden';
	}
	else {
		hideFavorite();
		//templateWindow.style.display='block';
		templateWindow.style.visibility = 'visible';
	}
}

function hideTemplate() {
	var templateWindow = document.getElementById('templatelist');
	//templateWindow.style.display = 'none';
	templateWindow.style.visibility = 'hidden';
}


function showFavorite2() {
	var favoriteWindow = document.getElementById('favoritelist');
	//alert(favoriteWindow.style.visibility);
	if (favoriteWindow.style.visibility=='visible') {
		favoriteWindow.style.visibility='hidden';
	}
	else {
		favoriteWindow.style.visibility='visible';
	}
}

function hideFavorite2() {
	var favoriteWindow = document.getElementById('favoritelist');
	favoriteWindow.style.visibility = 'hidden';
}

function showTemplateList2() {
	var templateWindow = document.getElementById('templatelist');
	
	if (templateWindow.style.visibility=='visible') {
		templateWindow.style.visibility='hidden';
	}
	else {
		templateWindow.style.visibility='visible';
	}
}

function hideTemplate2() {
	var templateWindow = document.getElementById('templatelist');
	templateWindow.style.visibility = 'hidden';
}


function play_stop_music(music) {
	//var md = document.getElementById('music_div');
	var mp = document.getElementById('music_panel');
	var me = document.getElementById('music_panel_embed');
	var mi = document.getElementById('music_icon');

	if (isIE())	{
		if (mp.className=="music_hidden") {
			//mp.setAttribute('URL',music);
			//me.setAttribute('autostart','true');
			mp.className = "music_visible";
			mi.className = "right";
		}
		else {			
			//mp.setAttribute('URL','');
			//me.setAttribute('autostart','false');
			mp.className = "music_hidden";
			mi.className = "tools_music_silent";
		}

	}	
	else {
		if (me.getAttribute('class')=="music_hidden") {
			//me.setAttribute('src',music);
			//me.setAttribute('autostart','true');
			//me.setAttribute('play','0');
			//alert(me.getAttribute('class'));
			me.className = "music_visible";
			mi.className = "right";
		}
		else {
			//me.setAttribute('src','');
			//me.setAttribute('autostart','false');
			//me.setAttribute('play','1');
			me.className = "music_hidden";
			mi.className = "tools_music_silent";		
		}

	}
}


function getCookie(c_name) {
	if (document.cookie.length>0) {
	  c_start = document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) { 
		c_start=c_start + c_name.length+1 ;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return null;
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	//exdate.setDate(exdate.getDate()+expiredays);
	exdate.setTime(exdate.getTime()+expiredays*60*60*24*1000);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function setTemplate(id) {
	setCookie('my_template', id, 100);
	window.location.reload();
}


function setCookie2(name, value)
{
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString())) +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +((secure == true) ? "; secure" : "");
}
