// JavaScript Document

//Basic redirect
function solcolRedirect(url){
	var sQueryString = "";
	var sTheme = "solcoltheme=";
	var sAddress = window.location.href.split('?');
	if(typeof(url)!=='undefined'){
		if(typeof(url)==='string'){
			if(solcolIsTheme(url)){
				sTheme = sTheme+url.toLowerCase()
				if(window.location.search!=""){
					sQueryString = solcolRemoveQueryTheme();
					if(sQueryString=="?"){
						sQueryString = sQueryString+sTheme;
					}else{
						sQueryString = sQueryString+"&"+sTheme;	
					}	
				}else{
					sQueryString = "?"+sTheme;	
				}
				window.top.location = sAddress[0]+sQueryString;
			}else{
				window.top.location = url;
			}
		}
	}else{
		window.top.location = window.location;
	}
}

//is Theme
function solcolIsTheme(theme){
	var bReturn = false;
	var sTheme = "";
	var regTheme = /^[a-z]{5,10}$/i;
	var sThemes = "|default|academic|basic|corporate|creative|kiosk|nature|relaxation|retro|technical|";
	if(typeof(theme)==='string'){
		if(theme.search(regTheme)>-1){
			sTheme = theme.toLowerCase();
			if(sThemes.indexOf("|"+sTheme+"|")>-1){
				bReturn = true;
			}
		}
	}
	return bReturn;
}

//get param value from querystring
function solcolGetQueryTheme(){
//get param value from querystring
	var sReturn = "";
	var sParam = "solcoltheme";
	var regParam = new RegExp('[\?&]{1}'+sParam+'=','i');
	var regValuePair = new RegExp('[\?&]{1}'+sParam+'=[a-z]{5,10}','i');
	if(window.location.search!=""){
		sValue = window.location.search;
		sValue = sValue.match(regValuePair)+"";
		sValue = sValue.replace(regParam,'');
		if(solcolIsTheme(sValue)){
			sReturn = sValue.toLowerCase();
		}
	}
	return sReturn;
}

//get param value from querystring
function solcolRemoveQueryTheme(){
	var sReturn = "";
	var regValuePair = /[\?&]{1}solcoltheme=[a-z]{5,10}/gi; 
	if(window.location.search!=""){
		sReturn = window.location.search.replace(regValuePair,'');
		if(sReturn.indexOf('?')!=0){
			sReturn = "?"+sReturn;
		}
	}
	return sReturn;
}

//Navigation mouseover
function solcolNavover(child,parent){
	if(!burstBubble(parent,child)){
		document.getElementById(child).style.top = document.getElementById('nav'+child).offsetTop+"px";
		document.getElementById(child).style.left = document.getElementById('nav'+child).offsetLeft+"px";
		document.getElementById(child).style.display = "block";
	}
}

//Navigation mouseout
function solcolNavout(child,parent){
	if(!burstBubble(parent,child)){
		document.getElementById(child).style.display = "none";
	}
}

//Stop bubbling
function burstBubble(parent,child) {
	var bReturn = false;
	if(typeof(window.event)!='undefined'){
		if(typeof(window.event.toElement)==='object'){
			if(window.event.toElement.parentNode.id==child||window.event.toElement.parentNode.id==parent||(window.event.fromElement.parentNode.id==child&&window.event.toElement.id==parent)){
				bReturn = true;	
			}
		}
	}
	if(bReturn){
		event.cancelBubble = true;
		event.returnValue = false;	
	}
	return bReturn;
}