// JavaScript Document
var sInt = 0;
function showImgLink(){
	hideOpacityObject();
	for (var i = 1; i <= 11; i++){
		document.getElementById("img" + i).style.display = "inline";
	}
}

function loadpage(){
	for (var i = 1; i <= 10; i++){
		document.getElementById("imgfl" + i).style.display = "inline";
	}
	
	for (var i = 2; i <= 4; i++){
		document.getElementById("img1" + i).style.display = "inline";
	}
	initPopUp();
	setTimeout("showImgLink()",1000);
}

function hideOpacityObject(){
	var objeto = "#imgInstructions";
	var caida = "0%";
	$(objeto).animate({ 
			opacity: 0.0,
			marginTop: caida
		}, 50 ).hide("slow");
	
	setTimeout("showOpacityObject()",500);

	for (var i = 1; i <= 10; i++){
		var objeto = "#imgfl" + i;
		var caida = "0%";
		$(objeto).animate({ 
				opacity: 0.0,
				marginTop: caida
			}, 1000 ).hide("slow");
	}
}
function showOpacityObject(){
	var objeto = "#imgInstructions";
	var caida = "0%";
	
	$(objeto)
		.animate({
			opacity: '0.0',
			marginTop: "0"
		}, 0 ).show()
		.animate({ 
			opacity: '1.0',
			marginTop: "0"
		}, 1000 ).show();
}
/****************************************/
function openWindow(url, windowHeight, windowWidth, resize, Name, Mode, MySendArgs, endFunction){           
      windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
      windowTop  = ((screen.availHeight / 2) - (windowHeight / 2)) - 20; 

	var mUrl = new String(window.location.pathname + url);
      var mResize = "";
      if (typeof(Mode) == "undefined" || Mode == 1){
            if (resize == null){
                  mResize = "resizable=false";
            }else{
                  mResize = "resizable=" + (resize ? "yes":"no");
            }
            if (Name == null) {
                  var newWindow = window.open(url, "", mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
                  return newWindow;
            }else{
                  var newWindow = window.open(url, Name, mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
                  return newWindow;
            }
      }
      else{
            _DialogArguments = MySendArgs
            _CurrentWindow = showPopWin(url, windowWidth, windowHeight + 60, endFunction)
      }

}
function openSendEmail(){
	var url = getURLRoot() + "/firstcom_virtual_booth/contact_form/index.php";
	openWindow(url, 220, 320,"","mail",2,null,null);
}
function getURLRoot(){
    var currentUrl = new String(document.location.pathname);
	var mUrlSegments = currentUrl.split("/");
	var supportUrl = document.location.protocol + "//" + document.location.host;
	return supportUrl;
}

function Left(s, n){
	// Devuelve los n primeros caracteres de la cadena
	if(n>s.length)
		n=s.length;
		
	return s.substring(0, n);
}
function InStr(n, s1, s2){
	var numargs=InStr.arguments.length;
	
	if(numargs<3)
		return n.indexOf(s1)+1;
	else
		return s1.indexOf(s2, n)+1;
}
function Right(s, n){
	// Devuelve los n últimos caracteres de la cadena
	var t=s.length;
	if(n>t)
		n=t;
		
	return s.substring(t-n, t);
}
function Mid(s, n, c){
	// Devuelve una cadena desde la posición n, con c caracteres
	// Si c = 0 devolver toda la cadena desde la posición n
	
	var numargs=Mid.arguments.length;
	
	// Si sólo se pasan los dos primeros argumentos
	if(numargs<3)
		c=s.length-n+1;
		
	if(c<1)
		c=s.length-n+1;
	if(n+c >s.length)
		c=s.length-n+1;
	if(n>s.length)
		return "";
		
	return s.substring(n-1,n+c-1);
}
function detectBrowser(){
    var mReturnValue = null
    var mAgent = new String(navigator.userAgent.toLowerCase())
    
    if (mAgent.indexOf("msie") !== -1){
        mReturnValue = "IE"
    }else if(mAgent.indexOf("firefox") !== -1){
        mReturnValue = "FF"
    }else if(mAgent.indexOf("safari") !== -1){
        mReturnValue = "SF"
    }
        
    return mReturnValue

}
/******** music on - off ***************************/
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function formSend(text){
	var tBrow = detectBrowser();
	if (tBrow=="FF"){
		var obj = getFlashMovie("soundfile");
		obj[1].setVol(text);
	}else{
		getFlashMovie("soundfile").setVol(text);
	}
}
function getTextFromFlash(str) {
	document.htmlForm.receivedField.value = "From Flash: " + str;   return str + " received";
}
/******** music on - off ***************************/
function midlink(){
	try{formSend('off');}catch(ex){}
	var url = "http://www.youtube.com/watch?v=YVDc6KsJ0aM";
	window.open(url)
}