// JavaScript Document
var content_folder 		= new Array('','blog','contact','products','portfolio','about','home');
var page_content 		= new Array('','detail.php','detail.php','detail.php','detail.php','detail.php');
var url_name 			= new Array('','blog','contact','products','portfolio','about','home');
var menu_name 			= new Array('','blog','contact','products','portfolio','about','home');

var root_short			= 'awink';
var has_scroll			= false;

var fx_mouse_overs		= new Array;
var fx_inner_content_menu;
var fx_inner_content;

var q_str_page			= '';
var q_str_item			= 0;
var active_current		= 1;
var active_menu			= 1;




var active_categories	= 0;
var active_parent		= 0;
var active_item			= 0;
var active_position		= 0;

var display_methods		= new Array('thumbs','rows','one');
var display_method		= 0;

var minimized			= true;
var left_pos			= 0;

var mySpinner;
var navigating			= false;

var url_to_load;
var allow_click			= true;

var swf_load_item		= false;
var swfOveruler			= false;

function LoadPageAll(basis_url, pagina, basis_item){
	$('main_container').setStyle('left' , 0);
	$('main_container').setStyle('top' , 0);
	
	hasFlash();
	
	var swap = new MooSwap('.page-menu');
	
	fx_inner_content 	 			= MorpheItems('inner_content', 800, Fx.Transitions.Cubic.easeOut);
	fx_inner_content_menu 			= MorpheItems('inner_content_menu', 800, Fx.Transitions.Cubic.easeOut);
	
	q_str_page			= pagina;
	q_str_item			= basis_item;
	
	firstResize();	
	
	
	
	if($('form_inschrijven')){
		setSomeForm('form_inschrijven','inschrijven_form','inschrijven_form','info_box', false, 'submit_btn')
	}
	
	window.onresize = function goResize(){resizing();}
}


var minWidth		= 940; //buffert of 20! basic width = 916 rounded gives 920 + 20
var minHeight		= 850; //buffert of 20! basic width = 916 rounded gives 920 + 20
function firstResize(){
	if(q_str_page=='portfolio' && q_str_item != 0){
		minHeight	= 1050;
	}
	
	if(q_str_page!='blog'){
		if(document.documentElement.clientWidth){
		
			innerWidth 	= getDocWidth();
			innerHeight	= getDocHeight();
			
			if(innerWidth<minWidth){
				innerWidth 	= minWidth;
			}
			if(innerHeight < minHeight){
				if(!browserIE){
					innerWidth 	= parseInt(innerWidth - 17);
				}
				innerHeight = minHeight;
				has_scroll	= true;
			}
		}else{
			innerWidth 	= minWidth;
			innerHeight = minHeight;
		}
	}else{
		innerWidth 	= parseInt((document.documentElement.clientWidth * 1)) - 17;
		innerHeight = 0;
	}
	positionAfterResize();
	
}

function resizing(){
	if(document.documentElement.clientWidth){
		if(!browserSAF){
			if(browserIE && browserIE8 == false){
				innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
			}else{
				innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
			}
			innerHeight	= parseInt((document.documentElement.clientHeight * 1));
		}else{
			innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
			innerHeight	= parseInt((document.documentElement.clientHeight * 1));
		}
		if(innerWidth<minWidth){
			innerWidth 	= minWidth;
		}
		if(innerHeight < minHeight){
			if(innerHeight > minHeight){ 
				if(!browserIE){
					if(!browserSAF){
						innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 17);
					}else{
						innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 16);
					}
				}
			}
			innerHeight = minHeight;
			has_scroll	= true;
		}
	}else{
		//alert(2)
		innerWidth 	= minWidth;
		innerHeight = minHeight;
	}
	positionAfterResize();
	

}


var maxWidth 			= 1080; //1080; //if 0 then innerwidth!
var av_width			= 0; //will be set
var maxHeight			= 455; //455; //if 0 then innerHeight!
var av_height			= 0; //will be set

function positionAfterResize(){
	middleX				= innerWidth / 2;
	middleY				= innerHeight / 2;
	
	$('navigation').setStyle('display' , 'block');
	$('footer').setStyle('display' , 'block');
	
	$('main_container').setStyle('display' , 'block');
}


/*item initing*/

function initPageItem(){
	fx_inner_content.set({'display': 'block'});
}

function initItemFinalize(){
	if(($('is_video') && $('is_video').value == 'yes' && $('video_id') && $('video_id').value != '')){
		video_id 		= $('active_item').value;
		//Log.log('video : variant 1 - '+video_id);
		initVideo();
	}if(($('is_music') && $('is_music').value == 'yes' && $('music_id') && $('music_id').value != '')){
		music_id 		= $('music_id').value;
		//Log.log('music : variant 1 (dus vanaf home) - '+music_id);
		initMusic();
	}if(($('is_product') && $('is_product').value == 'yes' && $('product_id') && $('product_id').value != '')){
		product_id 		= $('product_id').value;
		//Log.log('product : variant 1 (dus vanaf home) - '+product_id);
		initproduct();
	}else{
		initDetail(content_folder[active_current]);
		allow_click		= true;
		fxcontentShower.set({'opacity': 1, 'display': 'block'});
	}
}

function initDetail(page){
	switch(page){
		case 'portfolio':
			
			listing_thumb_list.each(function(element){
				listing_thumb_array.push(element.src);
			});	
			
			if(listing_thumb_array.length > 0 ){
				var myImages = new Asset.images(listing_thumb_array, {
					onComplete: function(){
						if(mySpinner){
						   mySpinner.destroy();
						}
						if($('detail_loader')){
							$('detail_loader').setStyle('display','none');
						}
						finalizePortfolio();
					}
				});	
			}else{								
				if(mySpinner){
				   mySpinner.destroy();
				}
				finalizePortfolio();
			}	
		break;
	}
}


/*end item initing*/













































var open_full = false;

function initPage(){
	//Log.log('listing : init : ' + url_name[active_current]);
}
function initLanguages(){
	if($('search_optionlanguage')){
		loadDropDownActions('search_optionlanguage','language');		
	}
}

var detail_width	= 565;


function navigateList(direction){
	if(allow_click){
		allow_click			= false;
		var current_page 	= parseInt($('page_nr').value);
		var current_cat 	= $('active_categories_name').value;
		var view			= $('viewoption').value;
		var countertje		= parseInt($('count_inlist').value);
		var this_page		= $('page').value;
		
		
		var current_parent 	= $('this_parents').value;
		var str_path 		= $('str_path').value;
		var path 			= $('path').value;
		
		var maxInList		= parseInt($('maxInList').value);
		switch(direction){
			case 1:
				//rechts // ouder bericht
				if(countertje > maxInList * current_page){
					allow_click		= true;
					current_page++;
				}
			break;
			case -1:
				//links // nieuwer bericht
				if(current_page>1){
					allow_click		= true;
					current_page--;
				}
			break;
		}
			
			
		if(allow_click){
		
			if($('listing_loader')){
				$('listing_loader').setStyle('display','block');
			}
			
			url_to_load				= root_domain + 'aanbod/listing.php?include_header=2&categories='+current_cat+'&parent='+current_parent+'&page_nr='+current_page+'&viewoption='+view+'&page='+this_page+'&str_path='+str_path+'&path='+path;
			
			
			var infoHider;
			var infoHider_target = 'listing_container';
			
			infoHider		= new Fx.Morph(infoHider_target, {duration: 400, transition: Fx.Transitions.Cubic.easeOut});
			infoHider.set({'opacity':0});
			loadNshow(url_to_load, 'listing_container', 'get', false);
			
		}else{
			allow_click			= true;
		}
	}
}

var active_view			= 'thumbs';
var count_inlist		= 0;
var fx_list_items		= new Array;
var items_inlist		= new Array;
var categories_inlist	= new Array;

function updateListingAfterViewOptionChange(){
	updateScroll('listing_container_scrollable', 'listing_container');	
}

var imgHider;
var infoHider;
var navigateItemStarted	= false;
	
function navigateItem(direction){
	if(allow_click == true){
			
		allow_click			= false;
		
		if(!navigateItemStarted){
			var items_inlist_str		= $('items_inlist').value;
			count_inlist				= $('count_inlist').value;
			var categories_inlist_str	= $('categories_inlist').value;
			items_inlist				= items_inlist_str.split(',');
			categories_inlist			= categories_inlist_str.split(',');
		}
		
		var current_active_item;
		if($('selected_article')){
			if($('articles_inlist')){
				var articles_inlist_str		= $('articles_inlist').value;
				var articles_inlist			= articles_inlist_str.split(',');
				current_active_item 		= $('selected_article').value;
				for(var i=0;i<count_inlist;i++){
					if(articles_inlist[i] == current_active_item){
						active_position	= i;
					}	
				}
			}else{
				current_active_item 		= active_item;
				for(var i=0;i<count_inlist;i++){
					if(items_inlist[i] == current_active_item){
						active_position	= i;
					}	
				}	
			}
		}else{
			current_active_item 		= active_item;
			for(var i=0;i<count_inlist;i++){
				if(items_inlist[i] == current_active_item){
					active_position	= i;
				}	
			}
		}
		
		//Log.log(active_position);
		
		switch(direction){
			case 1:
				//rechts // ouder bericht
				if(active_position < (count_inlist - 1) ){
					active_position++;
				}else{
					active_position	= 0;	
				}
			break;
			case -1:
				//links // nieuwer bericht
				if(active_position>0){
					active_position--;
				}else{
					active_position		= count_inlist - 1 ;
				}
			break;
		}
		
		var infoHider_target;
		var positionMove;
		
		
		if($('detail_image_container_sets')){
			if(navigateItemStarted){
				imgShower.cancel();
			}
			imgHider				= MorpheItems('detail_image_container_sets', 400, Fx.Transitions.Cubic.easeOut);
			imgHider.start({'opacity':0, 'top':0, 'left':0});	
			infoHider_target		= 'detail_content_container';
			positionMove			= true;
			
			if(navigateItemStarted){
				infoShower.cancel();
			}
		}else if($('detail_image_container')){
			
			//hideTabs();
			if(navigateItemStarted){
				imgShower.cancel();
			}
			imgHider				= MorpheItems('detail_image_content', 400, Fx.Transitions.Cubic.easeOut);
			imgHider.cancel();
			imgHider.start({'opacity':0});
			
			infoHider_target		= 'detail_info';
			positionMove			= true;
		
			if(navigateItemStarted){
				infoShower.cancel();
			}
		}else{
			infoHider_target		= 'inner_content_content';
			positionMove			= false;
		}
		
		infoHider		= new Fx.Morph(infoHider_target, {duration: 200, transition: Fx.Transitions.Cubic.easeOut, 
			onComplete: function(){
				gallery_opened_detail	= false;
				if($('detail_url_str')){
					
					var urls_string	= $('detail_url_str').value;
					var urls_array	= urls_string.split(',');
			
					var new_url		= urls_array[active_position];
					window.location = new_url;
				}else{
					openItem(items_inlist[active_position], categories_inlist[active_position], active_position, true);
				}
			}
		});
		
		navigateItemStarted		= true;	
			
		if(positionMove){
			infoHider.set({'opacity':0});
			infoHider.start({'opacity':0});		
		}else{
			infoHider.start({'opacity':0});	
		}
		
	}
}

function baseInitListingControls(loadImages){
	//Log.log('listing : config scroll & dropdown');
	fxcontentShower					= MorpheItems('listing_container', 400, Fx.Transitions.Cubic.easeOut);
	fxcontentShower.set({'opacity': 0, 'display': 'block'});									
	listing_thumb_array				= new Array;				
	listing_thumb_list				= $$('#inner_content_menu_listing img');
	initListLoadnShow(loadImages);
}

var fxcontentShower;
var listing_thumb
var listing_thumb_list;
var listing_thumb_array		= new Array;				
var fx_listing_thumb		= new Array;				
				
function processAfterClick(target, output){
	switch(target){
		case 'inner_content_menu_listing':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				baseInitListingControls(true);
			});
		break;
		case 'inner_content_menu':
		case 'listing_container':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				fxcontentShower					= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
				listing_thumb_array				= new Array;				
				listing_thumb_list				= $$('#listing_container img');
				
				if(target == 'inner_content_menu'){
					//at search whole listing is reloaded
					$('listing_container').setStyle('display','block');
				}
				
				initListLoadnShow(true);
			});
		break;
		case 'inner_content_content':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				fxcontentShower					= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
				listing_thumb_array				= new Array;				
				listing_thumb_list				= $$('#inner_content_content img');
				
				if($('form_login') || $('form_comment') ){
					//comments
					comments = true;
					if($('form_login')){
						setSomeForm('form_login','login_form','login_form','', false, 'submit_btn')
					}else{
						setSomeForm('form_comment','comment_form','comment_form','', false, 'submit_btn')
					}
				}
				
				initPageItem();
				initItemFinalize();
			});
		break;
		case 'create_shop_account':
		case 'login_area_content':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				
				if($('form_account')){
					ChangeAnim('height', $('login_area'), 200, 400, Fx.Transitions.Cubic.easeOut);
					ChangeAnim('height', $('login_area_background'), 180, 400, Fx.Transitions.Cubic.easeOut);
					setSomeForm('form_account','account_form','account_form','info_creation', false, 'submit_btn');
					allow_click		= true;
					
									
				}else if ($('form_account_shop')){
					setSomeForm('form_account_shop','account_form_shop','account_form_shop','info_creation', false, 'submit_btn');
					allow_click		= true;
					
					if($('search_optioncountry')){
						loadDropDownActions('search_optioncountry','country');		
					}
									
				}
				
				basicShow(target, false, true);
			});
		break;
		case 'items_suggest':
			$(target).innerHTML 	= output;
			$(target).addEvent('domready', function() {
				active_name_search	= false;
				mySpinner_search.toggle(target);
				mySpinner_search.destroy()
				$(target).setStyles({'opacity': 0.9});
			});
		break;
		case 'post_content':
		case 'comments':
			
			handleFlowResultBlog(target, output);
			
		break;
		case 'slides_container':
			
			allow_click		= true;
					
		break;
		case 'detail_content_container':
		case 'related_container_list':
		case 'product_add_cart':
		case 'cart_container':
		case 'checkout_container':
		case 'current_shipping_address':
		case 'current_payment_address':
		case 'checkout_shipping_method_content':
		case 'checkout_payment_method_content':
		case 'payment_address_selecter':
		case 'current_same_as_address':
		case 'product_info':
		case 'cart_listing_deleter_helper':
		case 'cart_listing_quantity_helper':
		case 'method_payment_container':
		case 'create_shipping_address_btn':
		case 'create_payment_address_btn':
		case 'checkout_shipping_content':
		case 'checkout_payment_content':
		case 'quicksearch':
		case 'cart_total_coupon':
			
			handleFlowResultShop(target, output);
			
			
		break;
		case 'city_selecter':
		case 'storelocator_result':
		case 'slides_container_home_info':
			handleFlowResult(target, output);
		break;
	};
}

function basicShow(target,animate,allowclick){
	
	
	fxcontentShower	= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
	if(animate){
		if(mySpinner){
		   mySpinner.hide();
		}
		fxcontentShower.start({'opacity': 1});
	}else{
		if(mySpinner){
		   mySpinner.destroy();
		}
		fxcontentShower.set({'opacity': 1});
	}
	
}


var basis_rows;
var row_height;
var loaded_rows;
var loaded_images;
var items_per_row;
var stepper			= 0;

var scroll_innited	= false;
var wanna_see		= 324;
//ik wil altijd de 324 (= 2 rijen thumbs / 4 rijen small thumbs (rows ;) ) voorlopen..

function loadImageRows(scrollPosition){
	////Log.log(scrollPosition + active_view);
	if(scrollPosition != 0){
		if(!scroll_innited){
			scroll_innited			= true;
			active_view				= $('viewoption').value;
			//Log.log('active view : ' + active_view);
			switch(active_view){
				case 'thumbs':
					wanna_see 		= 162;
					row_height 		= 162;
					loaded_rows 	= 5;
					basis_rows 		= 5;
					items_per_row	= 5;
					loaded_images	= loaded_rows * items_per_row;
				break;
				case 'rows':
					wanna_see 		= 81;
					row_height 		= 85;
					loaded_rows 	= 8;
					basis_rows 		= 8;
					items_per_row	= 10;
					loaded_images	= loaded_rows * items_per_row;
				break;
			}
		}
		
		////Log.log(Math.ceil(scrollPosition / wanna_see));
		
		if(stepper < Math.ceil(scrollPosition / wanna_see)){
			stepper++;
			if(loaded_images < (basis_rows + (2 * stepper)) * items_per_row){ //+2 want we laden er altijd 2 in!
				loaded_rows			= loaded_rows + 2;
				//Log.log('load new rows: '+ (loaded_rows -1) + ' & ' + loaded_rows);
				////Log.log('load new images: '+ loaded_images + ' -  ' + (new_rows_from + 1) * items_per_row);
				for(var j=loaded_images+1; j<=loaded_rows * items_per_row;j++){
					////Log.log('load new image: '+ j);
					var element 	= 'listing_thumb_'+ j;
					if($(element)){
						var tmb		= $('str_image_'+j).value
						loadNewTmb(element, new Array(tmb));
					}
				}
				loaded_images		= loaded_rows * items_per_row;			
			}
		}
	}
}

var busyBig		= false;
var inside_image = false;

function loadNewTmb(target, source){
	var loadedBig 	= new Array();
	new Asset.images(source, {
		onProgress: function(i) {
			//this.setStyles({
			//	'opacity': 0
			//});
			loadedBig[i] = this;
		},
		onComplete: function() {
			$(target).src = source;
		}
	});
}

function initListLoadnShow(loadImages){
	//Log.log('listing : mouse overs & na laden ('+ loadImages +') getoond');
	//loadImages is false of true... als afbeeldingen nog ingeladen moeten worden dan is ie true!
	if(loadImages){
		listing_thumb_list.each(function(element){
			listing_thumb_array.push(element.src);
		});	
		//alert(listing_thumb_array.length);
		if(listing_thumb_array.length > 0){
			var myImages = new Asset.images(listing_thumb_array, {
				onComplete: function(){
					initListShow();
				}
			});
		}else{
			initListShow();
		}
	}else{
		initListShow();			
	}
}


function initListShow(){
	
	var music_list			= $$('.listing-music-holder');
	music_list.each(function(element) {
		var current_music				= parseInt(element.getProperty('id').substring(13));
		music_array[current_music]		= false;
		element.addEvent('click', function(){
			var this_music				= parseInt(element.getProperty('id').substring(13));
			openMusic(this_music);
		});
	});
	if(mySpinner){
	   mySpinner.destroy();
	}
	if(active_form_busy){
		active_form_busy	= false;
		$('listing_container').unspin();
	}
	
	var page_nr			= parseInt($('page_nr').value);
	var countertje		= parseInt($('count_inlist').value);
	var maxInList		= parseInt($('maxInList').value);
	if(countertje < page_nr * maxInList){
		$('olderposts').setStyle('opacity',0);
		//$('olderposts_footer').setStyle('opacity',0);
		if(countertje == 0){
			$('inner_content_menu_listing').setStyle('background-image','none');
		}
	}else{
		$('olderposts').setStyle('opacity',1);
		//$('olderposts_footer').setStyle('opacity',1);
	}
	var current_page 	= $('page_nr').value;
	if(current_page==1){
		$('newerposts').setStyle('opacity',0);
		//$('newerposts_footer').setStyle('opacity',0);
	}else{
		$('newerposts').setStyle('opacity',1);
		//$('newerposts_footer').setStyle('opacity',1);
	}
	
	if($('listing_loader')){
		$('listing_loader').setStyle('display','none');
	}
	fxcontentShower.cancel();									
	fxcontentShower.set({'opacity': 1});									
	
	allow_click		= true;
}

function makeCall(target,str) {
	thisMovie(target).asFunc(str);
}

function resetDetail(){
	active_item								= 0;
	$('inner_content_content').innerHTML 	= '';
	active_position							= 0;
	fx_inner_content.cancel();
	fx_inner_content.start({'left':0, 'width':0});	
	open_full 								= false; // resetten want item is gesloten!
}

var new_top;
function openItem(items_id, categories, position, overrule_allow_click){
	////Log.log('open item : meaning : zet de indicator op de juiste plek / scroll listing indien nodig / laad het item in!');
	if(allow_click || overrule_allow_click){
		allow_click 							= false;
		active_item								= items_id;
		var soort_listing						= $('page').value;
		switch(soort_listing){
			case 'catalog': //products with articles
			
				var next_article				= 0;
				if($('articles_inlist')){
					var articles_inlist_str		= $('articles_inlist').value;
					var articles_inlist			= articles_inlist_str.split(',');
					var next_article			= articles_inlist[active_position]
				}
			
				url_to_load			= root_domain + '/catalog/detail.php?include_header=1&product='+items_id+'&article='+next_article+'&categories='+categories;
			break;
			case 'sets': //sets
				url_to_load			= root_domain + '/catalog/detail-sets.php?include_header=1&set='+items_id+'&categories='+categories;
			break;
			case 'blog': //blog
				url_to_load			= root_domain + 'blog/detail.php?include_header=1&item='+items_id+'&categories='+categories;
			break;
		}
		//alert(url_to_load);
		//$('inner_content_content').innerHTML 	= '';
		loadNshow(url_to_load, 'inner_content_content', 'get', false);
	}
}


function openItemLoad(url){
	loadNshow(url_to_load, 'inner_content_content', 'get', false);
}

var video_id;
var music_id;
var product_id;


function initItemFinalizeaaa	(){
	if(($('is_video') && $('is_video').value == 'yes' && $('video_id') && $('video_id').value != '')){
		video_id 		= $('active_item').value;
		//Log.log('video : variant 1 - '+video_id);
		initVideo();
	}if(($('is_music') && $('is_music').value == 'yes' && $('music_id') && $('music_id').value != '')){
		music_id 		= $('music_id').value;
		//Log.log('music : variant 1 (dus vanaf home) - '+music_id);
		initMusic();
	}if(($('is_product') && $('is_product').value == 'yes' && $('product_id') && $('product_id').value != '')){
		product_id 		= $('product_id').value;
		//Log.log('product : variant 1 (dus vanaf home) - '+product_id);
		initproduct();
	}else{
		initDetail(content_folder[active_current]);
		allow_click		= true;
		fxcontentShower.set({'opacity': 1, 'display': 'block'});
	}
}

function initDetailOld(page){
	switch(page){
		
		case 'blog':
		
			listing_thumb_list.each(function(element){
				listing_thumb_array.push(element.src);
			});	
			
			if(listing_thumb_array.length > 0 ){
				var myImages = new Asset.images(listing_thumb_array, {
					onComplete: function(){
						if(mySpinner){
						   mySpinner.destroy();
						}
						if($('detail_loader')){
							$('detail_loader').setStyle('display','none');
						}
						allow_click		= true;
	
					}
				});	
			}else{								
				if(mySpinner){
				   mySpinner.destroy();
				}
				if($('detail_loader')){
					$('detail_loader').setStyle('display','none');
				}
				allow_click		= true;
			}	
		
		break;
	}
}


function runFilter(){
	SendRequest('formfilter','listing_container','listing_container','listing_container');
}

var main_parent_name	= '';
var parent_name			= '';
var main_parent_id		= 0;
var parent_id			= 0;

function initFilter(){
	if($('filterform')){
		if($('search_optionfilter_0')){
			loadDropDownActions('search_optionfilter_0','filter_0');
		}
	}
}

function openVideoPopup(identifier){
	
	var new_url_mp4			= $('mp4_'+identifier).value;
	var new_url_ogv			= $('ogv_'+identifier).value;
	var new_url_webm		= $('webm_'+identifier).value;
	var video_ttl			= $('ttl_'+identifier).value;
	
	var myNEWVideoPopupBg = new Element('div', {
		'id': 'videoPopupBackground'
	});	
	
	myNEWVideoPopupBg.inject($('main_container'),'after');
	$('videoPopupBackground').setStyles({'width': innerWidth, 'height': getDocHeight(), 'opacity': 0.6, 'display':'block'});
	
	
	var myNEWVideoPopupTop = new Element('div', {
		'id': 'videoPopupTopMenu'
	});
	myNEWVideoPopupTop.inject($('main_container'),'after');
	$('videoPopupTopMenu').setStyles({'left': middleX - 320, 'display':'block'});

	var myNEWVideoPopupTop_NAME = new Element('div', {
		'id': 'videoPopupTopMenu_NAME'
	});
	var myNEWVideoPopupTop_CLOSE = new Element('div', {
		'id': 'videoPopupTopMenu_CLOSE'
	});
	
	
	myNEWVideoPopupTop_NAME.inject($('videoPopupTopMenu'));
	myNEWVideoPopupTop_CLOSE.inject($('videoPopupTopMenu'));
	$('videoPopupTopMenu_NAME').innerHTML	= video_ttl;
	
	myNEWVideoPopupTop_CLOSE.addEvent('click', function(){
		$('videoPopupBackground').destroy();
		$('videoPopupTopMenu').destroy();
		$('videoPopupContainter').destroy();
	});
	
	
	var myNEWVideoPopupContainer = new Element('div', {
		'id': 'videoPopupContainter'
	});
	myNEWVideoPopupContainer.inject($('main_container'),'after');
	$('videoPopupContainter').setStyles({'left': middleX - 320, 'display':'block'});
	
	
	if(browserIE){
		
		var obj = new Swiff(root_domain+'over-ons/video.swf', {
			id: 'videoPopupContainter_'+identifier,
			container: $('videoPopupContainter'),
			width: 640,
			height: 360,
			params: {
				wmode: 'window',
				bgcolor: '#000000'
			},
			vars: {
				direct_ttl: video_ttl,
				direct_url: new_url_mp4
			}
		})
		
		
	}else{
		
		var url = root_domain + 'over-ons/loadvideo.php?new_url_mp4='+new_url_mp4+'&new_url_ogv='+new_url_ogv+'&new_url_webm='+new_url_webm+'&frame_width=640&frame_height=360&browserIE='+browserIE+'&browserCHROME='+browserCHROME+'&browserFF='+browserFF;
		//alert(url);
		var req = new Request({url: url,
			method: 'get',
			onSuccess: function(responseText) {
				var output 	= req.response.text;
			
				
				$('videoPopupContainter').innerHTML = output;
				$('videoPopupContainter').addEvent('domready', function() {
				
				
				var myPlayer = VideoJS.setup("videoPopupPlayer");
				myPlayer.play();
				
				});
			},
			onFailure: function() {
				$('videoPopupContainter').set('innerHTML', 'The request failed.');
			}
		});
		req.send();
				
	}
	
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}
