/************************************************************
	USUAL SUSPECTS
************************************************************/
 
function get_div_y(id){
	obj = document.getElementById(id);
    var topValue = 0;
    while(obj){
		topValue += obj.offsetTop;
		obj = obj.offsetParent;
    }
	return topValue;
}

function get_div_x(id){
	obj = document.getElementById(id);
    var leftValue = 0;
    while(obj){
		leftValue += obj.offsetLeft;
		obj = obj.offsetParent;
    }
	return leftValue;
}

function get_scroll_x(){
	var scrOfX = 0;
	if(typeof(window.pageXOffset) == 'number'){
		//Netscape compliant
		scrOfX = window.pageXOffset;
	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
		//DOM compliant
		scrOfX = document.body.scrollLeft;
	} else if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		//IE6 standards compliant mode
		scrOfX = document.documentElement.scrollLeft;
	}
	return scrOfX;
}

function get_scroll_y() {
	var scrOfY = 0;
	if(typeof(window.pageYOffset) == 'number'){
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}

/************************************************************
	WINDOW SIZES
************************************************************/

var my_width = 0, my_height = 0;

function client_height(){
	
	if (typeof(window.innerWidth) == "number"){
		my_height = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		my_height = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)){
		my_height = document.body.clientHeight;
	}
	
	return my_height;
}

function scroll_height(){
	
	my_height = document.body.scrollHeight + 20;
	return my_height;
	
}

function client_width(){
	
	if (typeof(window.innerWidth) == "number"){
		my_width = window.innerWidth - 17;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		my_width = document.documentElement.clientWidth;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)){
		my_width = document.body.clientWidth;
	}
	
	return my_width;
}

/************************************************************
	
************************************************************/

function display_answer(id){
	if(document.getElementById("answer_" + id).style.display != "block"){
		document.getElementById("answer_" + id).style.display = "block";
		document.getElementById("answer_state_" + id).style.backgroundPosition = "bottom left";
	} else {
		document.getElementById("answer_" + id).style.display = "none";
		document.getElementById("answer_state_" + id).style.backgroundPosition = "top left";
	}
}

/************************************************************
	
************************************************************/

function createFlash(myName, myWidth, myHeight, ID) {

// if you are reading this then 

		var objHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="' + myWidth + '" height="' + myHeight + '"  id="' + ID + '">'
		objHTML += '<param name="movie" value="' + myName + '" />'
		objHTML += '<param name="quality" value="high" />'
		//objHTML += '<param name="wmode" value="transparent">'
		
		//objHTML += '<param name="SCALE" value="noborder" />'
		objHTML += '<param name="SCALE" value="exactfit"/>'
		objHTML += '<param name="AllowScriptAccess" value="always" />'
		objHTML += '<param name="allowFullScreen" value="true">'
		objHTML += '<embed src="' + myName + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  id="' + ID + '" width="' + myWidth + '" height="' + myHeight + '" allowScriptAccess="always"></embed>'
		objHTML += '</object>'
		
		document.write(objHTML);
	}


function set_contact(type){
	
	//alert(type);
	
	if(type == "contact_phone"){
		
		switch(country_id){
			case "0":
				document.getElementById("left_contact_into").innerHTML = "Please complete the form below and a member of the team will contact you.";
				document.getElementById("enquiry").innerHTML = "Reason for Enquiry:<span class=\"red\">*</span>";
				break;
			case "1":
				document.getElementById("left_contact_into").innerHTML = "Bitte fuellen Sie das untenstehende Formular aus und es wird sich schnellstmoeglich ein Mitglied unseres Teams bei Ihnen melden.";
				document.getElementById("enquiry").innerHTML = "Grund f&uuml;r die Kontaktanfrage:";
				break;
		}
		
		document.getElementById("left_contact_info").innerHTML = "";
		document.getElementById("email_label").style.display = "none";
		document.getElementById("email").style.display = "none";
		document.getElementById("phone_label").style.display = "block";
		document.getElementById("phone").style.display = "block";
		document.getElementById("country_code_label").style.display = "block";
		document.getElementById("country_code").style.display = "block";
		document.left_contact.required.value = "name,phone,country_code,enquiry";
		
	} else if(type == "contact_email"){
		
		switch(country_id){
			case "0":
				document.getElementById("left_contact_into").innerHTML = "Please use the form below to send us an email.";
				document.getElementById("enquiry").innerHTML = "Reason for Enquiry: <span class=\"red\">*</span>";
				break;
			case "1":
				document.getElementById("left_contact_into").innerHTML = "Bitte f&uuml;llen Sie dieses Formular aus.";
				document.getElementById("enquiry").innerHTML = "Grund f&uuml;r die Kontaktanfrage: <span class=\"red\">*</span>";
				break;
		}
		
		document.getElementById("left_contact_info").innerHTML = "";
		document.getElementById("email_label").style.display = "block";
		document.getElementById("email").style.display = "block";
		document.getElementById("phone_label").style.display = "none";
		document.getElementById("phone").style.display = "none";
		document.getElementById("country_code_label").style.display = "none";
		document.getElementById("country_code").style.display = "none";
		document.left_contact.required.value = "name,email,enquiry";
		
	}
}

function email_this_page(){
	
	url = "http://www.itelebill.com" + unescape(window.location.pathname);
	
	var x;
	
	if(window.XMLHttpRequest) {
		x = new XMLHttpRequest;
	} else {
		try {
			x = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				x = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				x = false;
			}
		}
	}
	
	if (x){
		x.onreadystatechange = function(){
			if (x.readyState == 4){
				
				//alert(x.responseText);
				if(document.getElementById("right_email_holder").innerHTML == ""){
					document.getElementById("right_email_holder").innerHTML = x.responseText;
					scroll_body(get_div_y("right_email_holder") - 50, 20);
				}
				
			}
		}
		
		x.open("GET", "/ajax/email_this_page.php?url=" + url, true);
		//x.open("GET", "../ajax/email_this_page.html", true);
		x.send(null);
		
		
		
	}
	
}


var scroll = 0;
function scroll_body(end_position, speed){
	
	scroll = get_scroll_y();
	
	if(end_position > scroll){
		animation_timer = setInterval("scrolling_body_down(" + end_position + ")", speed);
	} else {
		animation_timer = setInterval("scrolling_body_up(" + end_position + ")", speed);
	}
	
}

function scrolling_body_down(end_position){
	
	scroll = scroll + 15;
	
	if(scroll < end_position){
		window.scrollBy(0, 15);
	} else {
		scroll = 0;
		clearInterval(animation_timer);
	}
	
}

function scrolling_body_up(end_position){
	
	scroll = scroll - 15;
	
	if(scroll > end_position){
		window.scrollBy(0, -15);
	} else {
		scroll = 0;
		clearInterval(animation_timer);
	}
	
}
	
function email_name(){
	//alert(document.right_email.name.value);
		
	switch(country_id){
		case "0":
			string_replace = "You have been sent a";
			if(document.right_email.message.value.indexOf(string_replace) != -1){
				document.right_email.message.value = document.right_email.name.value + " has sent you a" + document.right_email.message.value.slice(document.right_email.message.value.indexOf(string_replace) + string_replace.length, document.right_email.message.value.length);
			}	
			break;
		case "1":
			document.right_email.message.value = document.right_email.name.value + " hat Ihnen einen Link zu itelebill.com geschickt. " + "http://www.itelebill.com" + unescape(window.location.pathname) + " Gr&uuml;sse. Ihr itelebill.com eam";
			break;
	}
	
}

	
function message_changed(){
	document.right_email.changed.value = "1";
}

function strip_url(){
	
	form_element = document.right_email.message.value;
	site_url = "http://www.itelebill.com";
	
	
	url_open = form_element.indexOf("http");
	url_close = form_element.indexOf("	", form_element.indexOf(site_url));
	
	before = form_element.slice(0, url_open);
	
	after = form_element.slice(url_close, form_element.length);
	my_string = before + "{URL}" + after;
	
	return my_string.replace(/ /g, "%20");
}
	
/**************************************************
	SEND FORM
**************************************************/

var x;
var contact_required = new Array("name", "email", "enquiry");
var content_owner_support_required = new Array("type", "name", "username", "email", "issue");
var customer_support_required = new Array("name", "email", "mobile_number", "country", "detail");
var right_email_required = new Array("name", "email", "message");
var content_owner_signup_required = new Array("name", "email", "phone");

var error_message_text = new Array();

//var right_contact_required = new Array("name", "email", "enquiry");

function check_form(url, form_name){
	
	//alert(document[form_name].contact_type.length);
	//alert(document[form_name].elements);
	
	if(form_name == "right_contact"){
		right_contact_required = document.right_contact.required.value.split(",");
	} else if(form_name == "left_contact"){
		left_contact_required = document.left_contact.required.value.split(",");
	}//
	
	document.getElementById(form_name + "_loader").innerHTML = "<img src=\"/images/loader.gif\">";
	
	//document[form_name].send.disabled = "true"
	//document[form_name].send.setAttribute("class", "button button_disabled");
	
	error_message = "";
	url_string = "";
	
	 for(i=0; i < document[form_name].elements.length; i++){
		
		
		///*
		if(document[form_name].elements[i].name.toLowerCase() != "submit" && document[form_name].elements[i].name.toLowerCase() != "send" && document[form_name].elements[i].name.toLowerCase() != "reset"){
			
			//alert(document[form_name].elements[i].name.toLowerCase());
			
			if(document[form_name].elements[i].name.substr(0,3) != "cb_" && document[form_name].elements[i].name.substr(0,2) != "r_"){
				
				if(form_name == "right_email" && document[form_name].elements[i].name == "message"){
					url_string += "message=" + strip_url() + "&";
				} else {
					url_string += document[form_name].elements[i].name + "=" + document[form_name].elements[i].value.replace(/ /g, "%20") + "&";
				}
				
				///*
				for (x in this[form_name + "_required"]){
					
					///*
					if (document[form_name].elements[i].name.toLowerCase() == this[form_name + "_required"][x]){
						
						//alert(document[form_name].elements[i].name.toLowerCase() + " || " + this[form_name + "_required"][x] + " |=| " + document[form_name].elements[i].value);

												
						if(document[form_name].elements[i].value == "" || document[form_name].elements[i].value.toLowerCase() == ("select " + document[form_name].elements[i].name)  || document[form_name].elements[i].value == "non_selected")  {
							
							switch(document[form_name].elements[i].name){
								
								case "to":
									error_message_text[0] = "<p>Please enter your Friends Email Address</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie die Email der Person ein an die Sie unseren Link schicken m&ouml;chten</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "name":
									error_message_text[0] = "<p>Please enter your Name</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie Ihren Namen ein</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "issue":
									error_message_text[0] = "<p>Please enter your Issue or Question</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie Ihre Frage ein</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "mobile_number":
									error_message_text[0] = "<p>Please enter your Mobile Phone Number to help us track our records</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie hier Ihre Mobiltelefonnummer ein</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "detail":
									error_message_text[0] = "<p>Please enter the nature of your problem</p>\n";
									error_message_text[1] = "<p>Bitte teilen Sie uns hier Ihr Anliegen mit</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "phone":
									error_message_text[0] = "<p>Please enter your Phone Number</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie hier Ihre Telefonnummer ein</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;
									
								case "email":
									if(form_name == "right_email"){
										error_message_text[0] = "<p>Please enter the Email Address you wish to send to</p>\n";
										error_message_text[1] = "<p>Bitte geben Sie hier die Email Adresse ein an die Sie dies weitersenden m&ouml;ten</p>\n";
										error_message += error_message_text[parseFloat(country_id)];
									} else {
										error_message_text[0] = "<p>Please enter your Email Address</p>\n";
										error_message_text[1] = "<p>Bitte geben Sie hier Ihre Email Adresse ein</p>\n";
										error_message += error_message_text[parseFloat(country_id)];
									}
									break;
									
								case "enquiry":
									error_message_text[0] = "<p>Please enter the nature of your Enquiry</p>\n";
									error_message_text[1] = "<p>Bitte geben Sie die Art Ihrer Anfrage</p>\n";
									error_message += error_message_text[parseFloat(country_id)];
									break;

								default:
									error_message += "<p>Please enter your " + document[form_name].elements[i].name + "</p>\n";
								
							}
							
						}
						
					}
					//*/
				}
			//*/
			} else if(document[form_name].elements[i].name.substr(0,3) == "cb_"){
				
				url_string += document[form_name].elements[i].name + "=" + document[form_name].elements[i].checked + "&";
				
			} else if(document[form_name].elements[i].name.substr(0,2) == "r_"){
				
				for(r = 0; r < document[form_name][document[form_name].elements[i].name].length; r++){
					if(document[form_name][document[form_name].elements[i].name][r].checked == true){
						val = document[form_name][document[form_name].elements[i].name][r].value;
					}
				}
				
				url_string += document[form_name].elements[i].name.substr(2, document[form_name].elements[i].name.length) + "=" + val + "&";
				//alert(document[form_name].elements[i].name.substr(2, document[form_name].elements[i].name.length) + ": " + val);
				
			}
			
		}
		//*/
	 }
	
	if(error_message != ""){
		
		switch(country_id){
			case "0":
				document.getElementById(form_name + "_info").innerHTML = "<div class=\"error_notice\"><h5>Oops! Please Correct The Following Errors</h5>" + error_message + "</div>";
				break;
			case "1":
				document.getElementById(form_name + "_info").innerHTML = "<div class=\"error_notice\"><h5>Uups! Bitte berichtigen Sie die folgenden Felder</h5>" + error_message + "</div>";
				break;
		}
		
		document.getElementById(form_name + "_loader").innerHTML = "";
	
		//document[form_name].send.disabled = "false"
		//document[form_name].send.setAttribute("class", "button");
	
	} else {
		
		send_form(url, url_string, form_name);
		//alert("sending: " + url_string);
		
	}
	
	return false;
	
}

function send_form(url, url_string, div){

	var params = url_string;
	//document.getElementById("testing").innerHTML = url_string;
	
	if (document.getElementById){
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	}

	if (x){
		x.onreadystatechange = function(){
			if (x.readyState == 4 && x.status == 200) {
				
				document.getElementById(div + "_loader").innerHTML = "";
	
				//document[div].send.disabled = "false"
				//document[div].send.setAttribute("class", "button");
				
				document.getElementById(div + "_info").innerHTML = "<div class=\"success_notice\">" + x.responseText + "</div>";
				
			}
		}
		
		x.open("POST", url, true);
		
		x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		x.setRequestHeader("Content-length", params.length);
		x.setRequestHeader("Connection", "close");
	
		x.send(params);
		
	}
}

function capitilise_words(input_string){

	var tmpStr, tmpChar, preString, postString, strlen;
	tmpStr = input_string.toLowerCase();
	stringLen = tmpStr.length;

	if (stringLen > 0){
		
		for (i = 0; i < stringLen; i++){
			if (i == 0){
				tmpChar = tmpStr.substring(0, 1).toUpperCase();
				postString = tmpStr.substring(1, stringLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(i, i+1);
				if (tmpChar == " " && i < (stringLen-1)){
					tmpChar = tmpStr.substring(i+1, i+2).toUpperCase();
					preString = tmpStr.substring(0, i+1);
					postString = tmpStr.substring(i+2, stringLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}

	return tmpStr;
	
}

/**************************************************
	SKYPE STATUS
**************************************************/

//window.onload = get_status;

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

function load_XML(xml_file){

	xmlDoc.async = "false";
	xmlDoc.onreadystatechange = verify;
	xmlDoc.load(xml_file);

	my_xml = xmlDoc.documentElement;
	firstNode = get_firstchild(my_xml);

	/*
		0: 'Unknow',
		1: 'Offline',
		2: 'Online',
		3: 'Away',
		4: 'Not avaiable',
		5: 'Do not disturb',
		6: 'Offline',
		7: 'Skype me!',
	*/

	//alert(firstNode.childNodes[0].childNodes[0].nodeValue);

	if (firstNode.childNodes[0].childNodes[0].nodeValue == 2){
		document.getElementById("online_chat").style.display = "block";
	} else {
		document.getElementById("online_chat").style.display = "none";
	}

}


function verify(){

	if (xmlDoc.readyState != 4){
		 return false;
	}

}

function get_firstchild(n){
	x=n.firstChild;
	while (x.nodeType!=1){
		x=x.nextSibling;
	}
	return x;
}

function get_status(){
	load_XML("http://next.itelebill.com/script/status.php");
}



function shrink_iframe(){
	
	//document.getElementById('demo_frame').height = "500px";
	//document.getElementById("loading").style.display = "block";
	//document.getElementById("mobile").style.display = "none";
	
}

function resize_iframe(){
	
	document.getElementById("loading").style.display = "none";
	
	var the_height = document.getElementById('demo_frame').contentWindow.document.body.scrollHeight;
	if(navigator.appName == "Microsoft Internet Explorer"){
		the_height += 50;
	}
	
    if(the_height < 900){
		if(the_height > 500){
			document.getElementById('demo_frame').height = the_height + "px";
		} else {
			document.getElementById('demo_frame').height = "600px";
		}
	} else {
		document.getElementById('demo_frame').height = "900px";
	}
	
	
}

function launch_popup(){
	
	if (document.getElementById("popup_alpha")){ 
		document.getElementById("popup_alpha").style.display = "block";
	} else {
		create_div('popup_alpha', 'absolute', '2', '0', '0', client_width(), client_height(), '');
	}
	
}

function launch_demo(flash_location, vid, script_location){
	
	launch_popup();
	
	if(flash_location == ""){
		flash_location = "../flash/demos/tutorial/";
	}
	
	if(script_location == ""){
		switch(country_id){
			case "0":
				script_location = "../flash/demos/tutorial/en/script.xml";
				break;
			case "1":
				script_location = "../flash/demos/tutorial/de/script.xml";
				break;
			case "2":
				script_location = "../flash/demos/tutorial/nl/script.xml";
				break;
		}
	}
	
	image_location = "../images/scenes/";
	
	var objHTML = '<table cellspacing="0" cellpadding="0">';
		objHTML += '<tr>';
		objHTML += '<td class="tl"></td>';
		objHTML += '<td class="t"></td>';
		objHTML += '<td class="tr"></td>';
		objHTML += '</tr>';
		objHTML += '<tr>';
		objHTML += '<td class="ml"></td>';
		objHTML += '<td class="m">';
		//objHTML += '<div id="loading" style="width: ' + (client_width() - 40) + 'px;height: ' + (client_height() - 40) + 'px;">';
		//objHTML += '<img style="top: ' + ((client_height() - (40 + 19)) / 2) + 'px;left: ' + ((client_width() - (40 + 220)) / 2) + 'px;" src="../images/loader.gif"></div>';
		//objHTML += '</div>';
		//objHTML += '<iframe src="/demo/demo_videos.html" width="' + (client_width() - 40) + '" height="' + (client_height() - 40) + '" border="0" id="demo_frame" name="demo_frame"></iframe>';
		//objHTML += '<iframe src="http://www.itelebill.com/demo/" width="660" height="100" border="0" id="demo_frame" name="demo_frame"></iframe>';
		//objHTML += '<iframe src="" width="660" height="100" border="0" id="demo_frame" name="demo_frame"></iframe>';
		//objHTML += '<iframe src="file:///C:/Projects/branches/stable/sites/itelebill.com/website2010/demo/demo_videos.html" width="' + (client_width() - 40) + '" height="' + (client_height() - 40) + '" border="0" id="demo_frame" name="demo_frame"></iframe>';
		
		objHTML += '<div id="flash_player_holder" style="width: ' + (client_width() - 40) + 'px;height: ' + (client_height() - 50) + 'px;">';
		
		objHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" name="flash_player" width="' + (client_width() - 80) + '" height="' + (client_height() - 260) + '" id="flash_player">';
		objHTML += '<param name="movie" value="' + flash_location + 'player.swf?vid=' + vid + '&script_url=' + script_location + '">';
		objHTML += '<param name="quality" value="high">';
		objHTML += '<param name="allowfullscreen" value="true">';
		
		//objHTML += '<embed src="' + flash_location + 'player.swf?script_url=' + script_location + 'script.xml" width="' + (client_width() - 80) + '" height="' + (client_height() - 260) + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="flash_player" allowfullscreen="true"></embed>';
		objHTML += '<embed src="' + flash_location + 'player.swf?vid=' + vid + '&script_url=' + script_location + '" width="' + (client_width() - 80) + '" height="' + (client_height() - 80) + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="flash_player" allowfullscreen="true"></embed>';
		
		objHTML += '</object>';
		/*
		objHTML += '<div id="scene_holder">';
	
		objHTML += '<h2>Scene Selection</h2>';
		
		objHTML += '<a href="javascript:void(0);" onclick="jump_frame(\'16\');">';
		objHTML += '<img src="' + image_location + 'instant_billing.jpg">';
		objHTML += 'Instant Billing';
		objHTML += '</a>';
	
		objHTML += '<a href="javascript:void(0);" onclick="jump_frame(\'58\');">';
		objHTML += '<img src="' + image_location + 'subscription_billing.jpg">';
		objHTML += 'Subscription Billing';
		objHTML += '</a>';
	
		objHTML += '<a href="javascript:void(0);" onclick="jump_frame(\'102\');">';
		objHTML += '<img src="' + image_location + 'streaming_services.jpg">';
		objHTML += 'Streaming Services';
		objHTML += '</a>';
	
		objHTML += '<div class="clear"></div>';

		objHTML += '</div>';
		*/
		objHTML += '</div>';
		
		
		objHTML += '</td>';
		objHTML += '<td class="mr"></td>';
		objHTML += '</tr>';
		objHTML += '<tr>';
		objHTML += '<td class="bl"></td>';
		objHTML += '<td class="b"></td>';
		objHTML += '<td class="br"></td>';
		objHTML += '</tr>';
		objHTML += '</table>';
	
	if (document.getElementById("iframe_holder")){ 
		document.getElementById("iframe_holder").style.display = "block";
		window.frames['demo_frame'].jump_frame('start');
	} else {
		// (id, position, zIndex, top, left, width, height, html){
		create_div('iframe_holder', 'fixed', '2', '10', '10', client_width() - 20, client_height() - 20, objHTML);
	}

	
}

function close_demo(){
	
	document.getElementById("popup_alpha").style.display = "none";
	document.getElementById("mobile").style.display = "none";
	document.getElementById("iframe_holder").style.display = "none";
	
	//document.getElementById('demo_frame').src = "/demo/demo_videos.html";
	window.frames['demo_frame'].jump_frame('stop');
}

function create_div(id, position, zIndex, top, left, width, height, html){

	var newdiv = document.createElement('div');
	newdiv.setAttribute("id", id);
	newdiv.id = id;

	newdiv.style.position = position;
	newdiv.style.zIndex = zIndex;

	if(left != ""){
		newdiv.style.left = left + "px";
	}
	
	if(top != ""){
		newdiv.style.top = top + "px";
	}
	
	if(width != ""){
		newdiv.style.width = width + "px";
	}
	
	if(height != ""){
		newdiv.style.height = height + "px";
	}
	
	newdiv.innerHTML = html;
   
	document.body.appendChild(newdiv);

}

function div_display(id, state){
	document.getElementById(id).style.display = state;
}

function simulate_step(step){
	
	demo_frame.simulate_step(step);
	
}

function jump_frame(frame){
	document["flash_player"].SetVariable("jump_frame", frame);
}


