  //<![CDATA[

  var smart_abo_checked = 0;
	var smart_abo_subscriber_id = 0;
	var callback_urls_waiting = 0;
	var callback_urls;
	var callback_type;

	function check_item_input_all(only_check) {
		var ok = 1;
		var set_focus = false;
		for (var i=0;i<input_elements.length;i++) {
		  var element = dom.byId(input_elements[i]);
		  if (element) {
		  	check_item_input(element)
		  	if (element.className != "ok") {
		  		ok = 0;
		  	}
		  	if (init && !set_focus) {
					element.focus();
					set_focus = true;
		  	}
		  }
		}
		if (ok && !only_check) {
			step_enable_next('item_input');
			if (init) dom.byId('msisdn').focus();
		}
		return ok;
	}


	function check_item_input(element) {

		if (element.id=="message_text") {
			if (element.value.length > 0) {
					element.className = "ok";
			} else {
				element.className = "";
			}
		}

		if (element.id=="message_recipient_msisdn") {
			if (element.value.length > 0) {
			  var ok = check_msisdn(element.value,network_prefixes);
				if (ok==0) {
					element.className = "error";
				} else if (ok==1) {
					element.className = "ok";
				} else {
					element.className = "";
				}
			} else {
				element.className = "";
			}
		}

	}

	function check_send_validation(element) {

		if (element.id=="mobile_operator_id") {
			if (element.value.length > 0) {
					element.className = "ok";
			} else {
				element.className = "";
				return;
			}
		}

		if (element.id=="msisdn") {
			if (element.value.length > 0) {
			  var ok = check_msisdn(element.value,network_prefixes);
				if (ok==0) {
					element.className = "error";
					return;
				} else if (ok==1) {
					element.className = "ok";
				} else {
					element.className = "";
				}
			} else {
				element.className = "";
				return;
			}
		}

		if (element.id=="gtc_read") {
		  if (element.checked == true) {
		    if (document.getElementById("gtc_read_text")) document.getElementById("gtc_read_text").style.textDecoration = 'none';
		    return true;
		  } else {
		    if (document.getElementById("gtc_read_text")) document.getElementById("gtc_read_text").style.textDecoration = 'blink';
		    return false;
		  }
		}

	}

	function process_send_validation() {

		if (!check_item_input_all(true)) {
			step_disable_all_next('item_input');
			return;
		}

		var gtc_read = dom.byId("gtc_read");
		if (gtc_read && gtc_read.style.display != 'none') {
		  if (!check_send_validation(gtc_read)) return;
		}

		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("msisdn");
		var device_company = dom.byId("device_company");
		var device_id = dom.byId("order_device_id");
		var button = dom.byId("button_send_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok" && (!device_id || device_id.className=="ok") && button.style.cursor != "wait") {

			if (smart_abo_id && smart_abo_checked) {
				dom.byId('send_validation_text_smart_abo').style.display = '';
				dom.byId('send_validation_text').style.display = 'none';
			} else {
				dom.byId('send_validation_text_smart_abo').style.display = 'none';
				dom.byId('send_validation_text').style.display = '';
			}

			step_disable_all_next('send_validation');

			hide_error("error_send_validation");
			button.style.cursor = "wait";

			var send_validation_type = subtype_id == 8 ? "erotic" : "";

			if (smart_abo_id) {
				if (!smart_abo_checked) {
					var post = 'cmd=check_smart_abo&smart_abo_id='+smart_abo_id+'&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value;
				} else if (mobile_operator_id.value == 40) { // there are no online orders for vodafone
					dom.byId('order_popup_vodafone_hu').style.display = '';
				} else {
					process_campaign_callback_counter(1);
					var post = 'cmd=send_validation&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&type='+send_validation_type;
				}
				new ajax('/mobile/abo/xml.fcgi', {postBody: post, onComplete: processed_send_validation, onError: error_send_validation});
			} else if (mobile_operator_id.value == 40 || mobile_operator_id.value == 41 || mobile_operator_id.value == 42) {
				dom.byId('order_popup_offline_info_hu').style.display = '';
			} else {
				var post = 'cmd=send_validation&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&type='+send_validation_type;
			      	new ajax('/shop/mobile/xml.fcgi', {postBody: post, onComplete: processed_send_validation, onError: error_send_validation});
			      	process_campaign_callback_counter(1);
      			}		
 		}
	}

	function processed_send_validation(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);

		dom.byId("button_send_validation").style.cursor = "pointer";

		if (smart_abo_id && !smart_abo_checked) {
			smart_abo_subscriber_id = parseInt(tr_xml.SmartAboSubscriberId[0].data);
			if (tr_xml.Ok[0].data == "1") {
				/* make abo download */
				get_smart_message_order();
			} else if (smart_abo_id == 33 || smart_abo_id == 34 || smart_abo_id == 35 || smart_abo_id == 42 || smart_abo_id == 43 || smart_abo_id == 44) {
				show_error("error_send_validation","Die Bestellung f&uuml;r dieses Produkt ist leider nicht mehr m&ouml;glich. Weitere tolle Angebote findest du auf <a href='http://www.blinkogold.de/'>www.blinkogold.de</a>");
			} else if (smart_abo_subscriber_id > 0) {
				/* make single download */
				smart_abo_id = 0;
				smart_abo_checked = 1;
				process_send_validation();
			} else {
				/* buy abo */
				if (tr_xml.AdditionalSmartAboSubscriberIds && tr_xml.AdditionalSmartAboSubscriberIds.length > 0) {
					/* show info layer that user will buy additional abo */
					document.getElementById('abo_info_text').style.display = '';
				}
				smart_abo_checked = 1;
				process_send_validation();
			}
		} else {
	  		if (tr_xml.Ok[0].data == "1") {
				step_enable_next('send_validation');
			} else {
				show_error("error_send_validation", tr_xml.Error[0].data);
			}
		}
	}

	function error_send_validation() {
		show_error("error_send_validation");
		dom.byId("button_send_validation").style.cursor = "pointer";
	}

	function process_order_product_smart_abo() {

		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("msisdn");
		var button = dom.byId("button_send_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok") {

			hide_error("error_send_validation");
			button.style.cursor = "wait";

			var post = 'cmd=order_product_smart_abo&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&products_id='+products_id+'&products_info='+escape(products_info)+'&products_action_value='+escape(products_action_value)+'&orders_products_info='+escape(orders_products_info);
			new ajax('/shop/mobile/xml.fcgi', {postBody: post, onComplete: processed_order_product_smart_abo, onError: error_order_product_smart_abo});
		}
	}

	function processed_order_product_smart_abo(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "2") {
		  smart_abo_checked = 0;
			step_enable_next('verify_validation');
			dom.byId("button_send_validation").style.cursor = "pointer";
		} else {
			smart_abo_id = 0;
			step_disable_all_next('send_validation');
			show_error("error_send_validation", tr_xml.Error[0].data);
			dom.byId("button_send_validation").style.cursor = "pointer";
		}
	}

	function error_order_product_smart_abo() {
		show_error("error_send_validation");
		dom.byId("button_send_validation").style.cursor = "pointer";
	}

	function check_verify_validation(element) {

		if (element.id=="validation_code") {
			element.className = "";
			return;
		}
	}

	function process_verify_validation() {

    document.getElementById('abo_info_text').style.display = 'none';
		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("msisdn");
		var validation_code = dom.byId("validation_code");
		var button = dom.byId("button_verify_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok" && button.style.cursor != "wait") {

			step_disable_all_next('verify_validation');

			hide_error("error_verify_validation");
			button.style.cursor = "wait";

			var verify_validation_type = subtype_id == 8 ? "erotic" : "";

			var post = 'cmd=verify_validation&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&code='+validation_code.value+'&type='+verify_validation_type;
			new ajax('/shop/mobile/xml.fcgi', {postBody: post, onComplete: processed_verify_validation, onError: error_verify_validation});
			process_campaign_callback_counter(2);
		}
	}

	function processed_verify_validation(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "1") {
			dom.byId("validation_code").className = "ok";
			get_smart_message_order();
		} else {
			dom.byId("validation_code").className = "error";

			show_error("error_verify_validation", tr_xml.Error[0].data);

			dom.byId("button_verify_validation").style.cursor = "pointer";
		}
	}

	function error_verify_validation() {
		show_error("error_verify_validation");
		dom.byId("button_verify_validation").style.cursor = "pointer";
	}

	var transaction_id = 0;

	function process_order_product() {

		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("msisdn");
		var validation_code = dom.byId("validation_code");
		var button = dom.byId("button_verify_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok" && validation_code.className=="ok" && transaction_id==0) {

			hide_error("error_verify_validation");
			button.style.cursor = "wait";

			var verify_validation_type = subtype_id == 8 ? "erotic" : "";

			var post = 'cmd=order_product&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&code='+validation_code.value+'&type='+verify_validation_type+'&products_id='+products_id+'&products_info='+escape(products_info)+'&products_action_value='+escape(products_action_value)+'&orders_products_info='+escape(orders_products_info);
			new ajax('/shop/mobile/xml.fcgi', {postBody: post, onComplete: processed_order_product, onError: error_order_product});
		}
	}

	function processed_order_product(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "2") {
			step_enable_next('verify_validation');
			dom.byId("button_verify_validation").style.cursor = "pointer";
			if (tr_xml.CallbackUrl) {
			  if (tr_xml.CallbackType[0].data == "image") {
			    callback_urls_waiting = tr_xml.CallbackUrl.length;
          var preloader = new ImagePreloader(tr_xml.CallbackUrl, callback_urls_loaded, '');
			  }
			}
		} else if (tr_xml.Ok[0].data == "1") {
			transaction_id = parseInt(tr_xml.TransactionId[0].data);
			window.setTimeout("process_check_transaction()",5000);
			if (tr_xml.Location[0].data) {
				dom.byId("order_popup").src = tr_xml.Location[0].data;
				dom.byId("order_popup").style.display = "";
			}
		} else {
			show_error("error_verify_validation", tr_xml.Error[0].data);
			dom.byId("button_verify_validation").style.cursor = "pointer";
		}
	}

	function error_order_product() {
		show_error("error_verify_validation");
		dom.byId("button_verify_validation").style.cursor = "pointer";
	}

	function process_check_transaction() {
		if (transaction_id > 0) {
			var post = 'cmd=check_transaction&transaction_id='+transaction_id+'&products_id='+products_id+'&products_info='+escape(products_info)+'&products_action_value='+escape(products_action_value)+'&orders_products_info='+escape(orders_products_info);
			new ajax('/shop/mobile/xml.fcgi', {postBody: post, onComplete: processed_check_transaction, onError: error_check_transaction});
		}
	}

	function processed_check_transaction(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "2") {
			transaction_id = 0;
			step_enable_next('verify_validation');
			dom.byId("button_verify_validation").style.cursor = "pointer";
		} else if (tr_xml.Ok[0].data == "1") {
			window.setTimeout("process_check_transaction()",5000);
		} else {
			show_error("error_verify_validation", tr_xml.Error[0].data);
			transaction_id = 0;
			dom.byId("button_verify_validation").style.cursor = "pointer";
		}
	}

	function error_check_transaction() {
		window.setTimeout("process_check_transaction()",5000);
	}

	function process_order_smart_abo() {

		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("msisdn");
		var validation_code = dom.byId("validation_code");
		var button = dom.byId("button_verify_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok" && validation_code.className=="ok" && smart_abo_subscriber_id==0) {

			hide_error("error_verify_validation");
			button.style.cursor = "wait";

  		var verify_validation_type = subtype_id == 8 ? "erotic" : "";

			var post = 'cmd=order_smart_abo&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&code='+validation_code.value+'&type='+verify_validation_type+'&smart_abo_id='+smart_abo_id+'&products_id='+products_id+'&products_info='+escape(products_info)+'&products_action_value='+escape(products_action_value)+'&orders_products_info='+escape(orders_products_info);
			new ajax('/mobile/abo/xml.fcgi', {postBody: post, onComplete: processed_order_smart_abo, onError: error_order_smart_abo});
		}
	}

	function processed_order_smart_abo(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "1") {
			smart_abo_checked = 0;
			smart_abo_subscriber_id = parseInt(tr_xml.SmartAboSubscriberId[0].data);
			window.setTimeout("process_check_order_smart_abo()",5000);
		} else {
			show_error("error_verify_validation", tr_xml.Error[0].data);
			dom.byId("button_verify_validation").style.cursor = "pointer";
		}
	}

	function error_order_smart_abo() {
		show_error("error_verify_validation");
		dom.byId("button_verify_validation").style.cursor = "pointer";
	}


	function process_check_order_smart_abo() {

		var msisdn = dom.byId("msisdn");

		if (smart_abo_subscriber_id > 0) {
			var post = 'cmd=check_order_smart_abo&msisdn='+msisdn.value+'&smart_abo_id='+smart_abo_id;
			new ajax('/mobile/abo/xml.fcgi', {postBody: post, onComplete: processed_check_order_smart_abo, onError: error_check_order_smart_abo});
		}
	}

	function processed_check_order_smart_abo(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "1") {
			step_enable_next('verify_validation');
			dom.byId("button_verify_validation").style.cursor = "pointer";
			if (tr_xml.CallbackUrl) {
			  if (tr_xml.CallbackType[0].data == "image") {
			    callback_urls_waiting = tr_xml.CallbackUrl.length;
          var preloader = new ImagePreloader(tr_xml.CallbackUrl, callback_urls_loaded, '');
			  }
			}
		} else if (tr_xml.Ok[0].data == "2") {
			window.setTimeout("process_check_order_smart_abo()",5000);
		} else {
			show_error("error_verify_validation", tr_xml.Error[0].data);

			smart_abo_subscriber_id = 0;
			dom.byId("button_verify_validation").style.cursor = "pointer";
		}
	}

	function error_check_order_smart_abo() {
		window.setTimeout("process_check_order_smart_abo()",5000);
	}

	var products_id = 0;
	var products_info = "";
	var products_action_value = "";
	var orders_products_info = "";

	function get_smart_message_order() {

		var mobile_operator_id = dom.byId("mobile_operator_id");
		var msisdn = dom.byId("message_recipient_msisdn");
		if (!msisdn) msisdn = dom.byId("msisdn");
		var device_id = dom.byId("order_device_id");
		var button = dom.byId("button_verify_validation");

		if (mobile_operator_id.className=="ok" && msisdn.className=="ok" && (!device_id || device_id.className=="ok")) {

			hide_error("error_verify_validation");
			button.style.cursor = "wait";

			var post = 'cmd=get_smart_message_order&mobile_operator_id='+mobile_operator_id.value+'&msisdn='+msisdn.value+'&item_id='+dom.byId("item_id").value;
			if (dom.byId("mono_class_id")) {
				post = post+'&class_id='+dom.byId("mono_class_id").value;
			} else {
				post = post+'&class_id='+dom.byId("class_id").value;
			}
			if (device_id) {
			  post = post+'&device_id='+device_id.value;
			} else {
				post = post+'&device_id='+dom.byId("device_id").value;
			}
			/* check for name wallpaper text */
			if (amount_text_lines) {
  		  post = post+'&amount_text_lines='+escape(amount_text_lines);
  		  for (var i=1;i<=amount_text_lines;i++) {
			    if (dom.byId('text_'+i)) post = post+'&text_'+i+'='+escape(dom.byId('text_'+i).value);
  		  }
  		}

			if (dom.byId("message_text")) post = post+'&message_text='+escape(dom.byId("message_text").value);
			if (dom.byId("audio_id")) post = post+'&audio_id='+dom.byId("audio_id").value;
			new ajax('/mobile/xml.fcgi', {postBody: post, onComplete: got_smart_message_order, onError: error_smart_message_order});
		}
	}

	function got_smart_message_order(request) {
		var tr_xml = dom.treeXML(request.responseXML.documentElement);
		if (tr_xml.Ok[0].data == "1") {
			products_id = tr_xml.ProductsId[0].data;
			products_info = tr_xml.ProductsInfo[0].data;
			products_action_value = tr_xml.ProductsActionValue[0].data;
			orders_products_info = tr_xml.OrdersProductsInfo[0].data;

			if (smart_abo_id && smart_abo_subscriber_id) {
			  process_order_product_smart_abo();
			} else if (smart_abo_id) {
				process_order_smart_abo();
			} else {
			  process_order_product();
			}
		} else {
			if (smart_abo_id) {
				show_error("error_send_validation", tr_xml.Error[0].data);
			  dom.byId("button_send_validation").style.cursor = "pointer";
			} else {
			  show_error("error_verify_validation", tr_xml.Error[0].data);
		  	dom.byId("button_verify_validation").style.cursor = "pointer";
		  }
		}
	}

	function error_smart_message_order() {
		show_error("error_verify_validation");
		dom.byId("button_verify_validation").style.cursor = "pointer";
	}

	function step_disable(step) {
		var table = dom.byId('step_'+step);
		var div_disable = dom.byId('step_disable_'+step);

		div_disable.style.width = (table.offsetWidth+1)+'px';
		div_disable.style.height = table.offsetHeight+'px';
		div_disable.style.visibility = "visible";
	}

	function step_enable(step) {
		var div_disable = dom.byId('step_disable_'+step);
		div_disable.style.visibility = "hidden";
	}

	function step_disable_all_next(step_name) {
		var start = 99;
		for (var i=0;i<steps.length;i++) {
			if (step_name == steps[i]) start = i+1;
			if (i >= start) step_disable(i);
		}
	}

	function step_enable_next(step_name) {
		for (var i=0;i<steps.length;i++) {
			if (step_name == steps[i]) {
				step_enable(i+1);
				return;
			}
		}
	}

	function init() {
	  init_step_4_text();
		step_disable_all_next('item_input');
		check_item_input_all(false,true);
	}

  function callback_urls_loaded(aImages, nImages, return_href) {
    if ( nImages != callback_urls_waiting ) {
      // Images didnt load properly
      if (dom.byId("image_load_info")) {
        dom.byId("image_load_info").innerHTML = '<b>Incomplete Image Load.</b>';
      }
    }
    // do nothing window.location.href = return_href;
  }


function ImagePreloader(imagesrcs, callback, return_href) {

   // store the call-back
   this.callback = callback;

   // store my return link
   this.return_href = return_href;

   // initialize internal state.
   this.nLoaded = 0;
   this.nProcessed = 0;
   this.aImages = new Array;

   // record the number of images.
   this.nImages = imagesrcs.length;

   // for each image, call preload()
   for ( var i = 0; i < imagesrcs.length; i++ )
      this.preload(imagesrcs[i].data);
}

ImagePreloader.prototype.preload = function(image) {
   // create new Image object and add to array
   var oImage = new Image;
   this.aImages.push(oImage);

   // set up event handlers for the Image object
   oImage.onload = ImagePreloader.prototype.onload;
   oImage.onerror = ImagePreloader.prototype.onerror;
   oImage.onabort = ImagePreloader.prototype.onabort;

   // assign pointer back to this.
   oImage.oImagePreloader = this;
   oImage.bLoaded = false;

   // assign the .src property of the Image object
   oImage.src = image;
}

ImagePreloader.prototype.onComplete = function() {
   this.nProcessed++;
   if ( this.nProcessed == this.nImages ) {
      this.callback(this.aImages, this.nLoaded, this.return_href);
   }
}

ImagePreloader.prototype.onload = function() {
   this.bLoaded = true;
   this.oImagePreloader.nLoaded++;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function() {
   this.bError = true;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function() {
   this.bAbort = true;
   this.oImagePreloader.onComplete();
}

function init_step_4_text() {
  if (!smart_abo_id) {return false;}

  var abo_type = '';
  if (smart_abo_id == 34 || smart_abo_id == 37 || smart_abo_id == 43) {
    abo_type = 'game';
  } else if (smart_abo_id == 33 || smart_abo_id == 36 || smart_abo_id == 42) {
    abo_type = 'entertainment';
  } else if (smart_abo_id == 35 || smart_abo_id == 38) {
    abo_type = 'erotic';
  }

  if (abo_type) {
    var default_layer_obj = document.getElementById('step_4_text_default');
    var abo_layer_obj = document.getElementById('step_4_text_smart_abo_'+abo_type);
    if (default_layer_obj && abo_layer_obj) {
      default_layer_obj.style.display = 'none';
      abo_layer_obj.style.display = '';
    }
  }
  return false;
}

  var registered_reminder_action = false;
  function process_campaign_callback_counter(step) {
    
    if (typeof cid != 'number' || cid < 1 || pid < 1 || lid < 1) {
      return false;
    }

    if (pid == '18') {
      //preload tracking pixel for iCrossing
      var tracking_urls = [];
      if (step == 1) {
        tracking_urls[tracking_urls.length] = {data: 'https://www.traffictrack.de/tracking/tracking.php?kunde=buongiorno&cat=2&cid=2&ordnr='+lid};
      } else if (step == 2) {
        tracking_urls[tracking_urls.length] = {data: 'https://www.traffictrack.de/tracking/tracking.php?kunde=buongiorno&cat=3&cid=3&ordnr='+lid};
      }
      var preloader = new ImagePreloader(tracking_urls, function(){}, '');
    }
    
    // call counter
    var post = 'cmd=step_counter&log_entry_id='+lid+'&campaign_id='+cid+'&partner_id='+pid+'&step='+step;
	  new ajax('/campaign/xml.fcgi', {postBody: post, onComplete: processed_campaign_callback_counter, onError: error_campaign_callback_counter});
  }
  function processed_campaign_callback_counter(request) {
  }
	function error_campaign_callback_counter() {
	}


//Headline für Handy Games oder für Restliche Seiten

var menu_toggle_compareurl_headline_p1 = location.href;
var menu_toggle_headline_p1 = menu_toggle_compareurl_headline_p1.match(/handy_spiele/i);

	
function menu_toggle_url_control_headline_p1(){	

		if(menu_toggle_headline_p1){

			document.getElementById("headline_handygames").style.display = "block";	
			document.getElementById("headline_default").style.display = "none";	
		}
		else{
			document.getElementById("headline_default").style.display = "block";	
			document.getElementById("headline_handygames").style.display = "none";		
		}		
}





//]]>

