//----------------------------------------------------------------------------
// INIT "TIP A FRIEND ABOUT PRODUCT "
//----------------------------------------------------------------------------
addOnLoad('init_tipFriendProduct()');
var intershopPrefixPath= "/is-bin/INTERSHOP.enfinity/WFS/Stadium-SwedenB2C-Site/sv_SE/-/SEC/";
function init_tipFriendProduct() {

	if( document.getElementById("tip_friend_product") ) {
		document.getElementById("tip_friend_product").onclick = tip_friendProduct;
	}
}

//----------------------------------------------------------------------------
// OPEN "TIP A FRIEND ABOUT PRODUCT" window
//----------------------------------------------------------------------------
function tip_friendProduct(header) {
	var ProductUUID = document.getElementById("ProductUUID").value;

	if(!document.getElementById("LitBox")) {
		litbox = new LITBox(intershopPrefixPath+'cc_ProductTipFriend-New' + '?ProductUUID=' + ProductUUID, {type:'window', overlay:true, height:320, width:420, resizable:true, opacity:1, header: header});
		litbox.focusFirstField();
	}
	return false;
}
//----------------------------------------------------------------------------
// SEND "TIP A FRIEND ABOUT PRODUCT"
//----------------------------------------------------------------------------
function send_tip_product(btn){
	var her_name 	= document.getElementById("tip_her_name").value;
	var her_email	= document.getElementById("tip_her_mail").value;
	var your_name	= document.getElementById("tip_your_name").value;
	var your_email 	= document.getElementById("tip_your_mail").value;
	var your_msg 	= document.getElementById("tip_text").value;

	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation
	
	if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' || !her_email.match(re) || !your_email.match(re) ) {
	
		if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' ) {
			tip_friend_alertShow('missing');
		} 
		else {
			if (!her_email.match(re) && !your_email.match(re) ) {
			tip_friend_alertShow('both');
			}
			else {
				if (!her_email.match(re) ) {
				tip_friend_alertShow('her');
				} 
				else {
					if (!your_email.match(re) ) {
					tip_friend_alertShow('your');
					}	
				}
			}
		}
	}
	else { 
		your_msg=encodeURIComponent(your_msg);
		your_name=encodeURIComponent(your_name)+' ';	
		her_name=encodeURIComponent(her_name);		
	
	
		var ProductUUID = document.getElementById('TipProductUUID').value;
		var queryString = "TipForm_HerName=" + her_name + "&TipForm_HerMail=" + her_email + "&TipForm_YourName=" + your_name + "&TipForm_YourMail=" + your_email + "&TipForm_Text=" + your_msg + "&ProductUUID=" +ProductUUID;
		//var url = document.getElementById('form_tip_friend').action.value;
				
		var myAjax = new Ajax.Updater("tip_friend_div", intershopPrefixPath+"cc_ProductTipFriend-Create" , {method: 'post', parameters: queryString});	

		showSubmitionLoader(btn);
	}
	return false;
}

//----------------------------------------------------------------------------
// OPEN "TIP A FRIEND About SHOP" 
//----------------------------------------------------------------------------
function tip_friendShop(header) {
	new LITBox('cc_UserShop-MailFriend',{type:'window', overlay:true, height:340, width:420, resizable:true, opacity:1, header: header});
	return false;
}

//----------------------------------------------------------------------------
// Supportive function, checks if an element exists in document
// input: element id as string (String)
//----------------------------------------------------------------------------
function elementObjectExists(objId) {
	return document.getElementById(objId) ? true:false;
}


//--------------------------------------------------------
// Open "Tip friend about public shop" 
//--------------------------------------------------------


function tip_friendPublicShop(header) {
	var shopuuid = document.getElementById("ShopUUID").value;
	new LITBox('cc_UserShop-TipFriend'+ '?ShopUUID=' + shopuuid,{type:'window', overlay:true, height:340, width:420, resizable:true, opacity:1, header: header});
	return false;
}

function send_tip_PublicShop(btn){
	
	var her_name 	= document.getElementById("tip_her_name").value;
	var her_email	= document.getElementById("tip_her_mail").value;
	var your_name	= document.getElementById("tip_your_name").value;
	var your_email 	= document.getElementById("tip_your_mail").value;
	var your_msg 	= document.getElementById("tip_text").value;

	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation

	if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' || !her_email.match(re) || !your_email.match(re) ) {
	
		if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' ) {
			tip_friend_alertShow('missing');
		} 
		else {
			if (!her_email.match(re) && !your_email.match(re) ) {
			tip_friend_alertShow('both');
			}
			else {
				if (!her_email.match(re) ) {
				tip_friend_alertShow('her');
				} 
				else {
					if (!your_email.match(re) ) {
					tip_friend_alertShow('your');
					}	
				}
			}
		}
	}else { 	
		your_msg=encodeURIComponent(your_msg);
		your_name=encodeURIComponent(your_name);
		her_name=encodeURIComponent(her_name);			
		var ShopUUID = document.getElementById("ShopUUID").value;
		var queryString = "TipForm_HerName=" + her_name + "&TipForm_HerMail=" + her_email + "&TipForm_YourName=" + your_name + "&TipForm_YourMail=" + your_email + "&TipForm_Text=" + your_msg + "&ShopUUID=" + ShopUUID;

		var myAjax = new Ajax.Updater("tip_friend_div", "cc_UserShop-TipFriendSend" , {method: 'post', parameters: queryString});	
		showSubmitionLoader(btn);

	}
	return false;
}









//--------------------------------------------------------
// Show popup alert message
//--------------------------------------------------------
/*
function tip_friend_alertShow() {
	document.getElementById('alert_overlay').style.display = 'block';
	document.getElementById('alert').style.display = 'block';
	return false;
}
*/
//--------------------------------------------------------
// Hide popup alert message
//--------------------------------------------------------
/*
function tip_friend_alertHide() {
	document.getElementById('alert_overlay').style.display = 'none';
	document.getElementById('alert').style.display = 'none';
	return false;
}
*/
function dialogSwitcher(msgElementId, overlayTarget) {
	
	// Check if dialog element exists
	if (!elementObjectExists('messageDialog')) return;
	dialogObj  = document.getElementById('messageDialog');

	// Create overlay element object if it doesn't exist
	if (!elementObjectExists( 'messageDoalogContainer' ) && elementObjectExists( overlayTarget )) {
		objToOverlay = document.getElementById( overlayTarget );
		overlayElement    = document.createElement('div');
		overlayElement.id = 'messageDoalogContainer';
		dialogObj.parentNode.appendChild(overlayElement, 'outside');
		
		overlayElement.style.width  = objToOverlay.style.width;
		overlayElement.style.height = objToOverlay.style.height;
	}
	// Hide open dialogs
	dialogObj.style.display      = "none";
	overlayElement.style.display = "none";	

	// Hide current message dialog
	if (dialogObj.currentOpenMessage) {
		currentObj = document.getElementById(dialogObj.currentOpenMessage);
		currentObj.style.display     = "none";
	}
	// Check if msgElementId exists or is false then return
	if (!elementObjectExists(msgElementId))	return;
	messageObj = document.getElementById(msgElementId);
		
	// Show dialog
	messageObj.style.display     = "block";
	dialogObj.style.display      = "block";
	overlayElement.style.display = "block";
	
	// Store currently opened dialog id
	dialogObj.currentOpenMessage = msgElementId;

	return false;
}
//--------------------------------------------------------
// Show popup alert message
//--------------------------------------------------------
function tip_friend_alertShow(alert) {
	document.getElementById('alert_overlay').style.display = 'block';
	document.getElementById('alert').style.display = 'block';
	if (alert=='missing')
	document.getElementById('missing').style.display = 'block';
	if (alert=='both')
	document.getElementById('both').style.display = 'block';
	if (alert=='her')
	document.getElementById('her').style.display = 'block';
	if (alert=='your')
	document.getElementById('your').style.display = 'block';
	if (alert=='check')
	document.getElementById('check').style.display = 'block';
	return false;
}
//--------------------------------------------------------
// Hide popup alert message
//--------------------------------------------------------
function tip_friend_alertHide(alert) {
	
	if (alert=='missing')
	document.getElementById('missing').style.display = 'none';
	if (alert=='both')
	document.getElementById('both').style.display = 'none';
	if (alert=='her')
	document.getElementById('her').style.display = 'none';
	if (alert=='your')
	document.getElementById('your').style.display = 'none';
	if (alert=='check')
	document.getElementById('check').style.display = 'none';
	
	document.getElementById('alert_overlay').style.display = 'none';
	document.getElementById('alert').style.display = 'none';
	return false;
}

//--------------------------------------------------------
// Tip friend about wishlist
//---------------------------------------------------------


function tip_friendWishlist(header) {
	new LITBox('cc_ViewUserWishlist-MailFriend',{type:'window', overlay:true, height:340, width:420, resizable:true, opacity:1, header: header});
	return false;
}


//--------------------------------------------------------
// SEND "Tip friend about..." 
//--------------------------------------------------------
function tip_friend_send(btn){
	var her_name 	= document.getElementById("InvitationForm_FriendName").value;
	var her_email	= document.getElementById("InvitationForm_MailTo").value;
	var your_name	= document.getElementById("InvitationForm_Message").value;
	
	var mailtype	= document.getElementById("InvitationForm_Mailtype").value;	
	
	
	// RegExp for mailadres validation (cjecks even the end of adress ex. ".s" or ".se")
	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation	

	

	if (her_name == '' || her_email == '' || your_name == ''){
		tip_friend_alertShow('missing');
	}
	else if (!her_email.match(re)) {
		tip_friend_alertShow('her');
	} else {
		your_name=encodeURIComponent(your_name);
		her_name=encodeURIComponent(her_name);		
		if(document.getElementById("InvitationForm_MailSelf")){
			if(document.getElementById("InvitationForm_MailSelf").checked){
				var your_email	= document.getElementById("InvitationForm_MailSelf").value;	
			}
		}

		if(document.getElementById("TopMenuSelected")){
			var TopMenuSelected = document.getElementById("TopMenuSelected").value;
		}
	
		var queryString = "InvitationForm_FriendName=" + her_name + "&InvitationForm_MailTo=" + her_email + "&InvitationForm_Message=" + your_name+"&InvitationForm_MailSelf=" + your_email+"&TopMenuSelected=" + TopMenuSelected+"&InvitationForm_Mailtype="+mailtype;
		if(mailtype=='shop'){
			var myAjax = new Ajax.Updater("tip_friend_div", "cc_UserShop-Invite" , {method: 'get', parameters: queryString});			
			showSubmitionLoader(btn);
		}else{
			var myAjax = new Ajax.Updater("tip_friend_div", "cc_ViewUserWishlist-Invite" , {method: 'get', parameters: queryString});
			showSubmitionLoader(btn);
		}

	}
	return false;
}



//--------------------------------------------------------
// Open "Tip friend about article" 
//--------------------------------------------------------

function tip_friendArticle(targetObj,article_uuid, Level4MenuSelected, TopMenuSelected, header) {

	// Hide flash video player, or it will hide the popup
	if( document.getElementById("StadiumVideoViewer") ) {
		document.getElementById("StadiumVideoViewer").style.visibility = "hidden";
	}
	
	//var article_uuid = document.getElementById("article").value;
	//var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
	//var TopMenuSelected = document.getElementById("TopMenuSelected").value;
	
	Level4MenuSelected=encodeURIComponent(Level4MenuSelected);
	
	new LITBox(targetObj.href+'?ArticleID=' + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected, {type:'window', overlay:true, height:340, width:420, resizable:true, opacity:1, header: header});
	return false;
}
//--------------------------------------------------------
// Send "Tip friend about article" 
//--------------------------------------------------------
function send_tip_article(btn){
	
	var her_name 	= document.getElementById("tip_her_name").value;
	var her_email	= document.getElementById("tip_her_mail").value;
	var your_name	= document.getElementById("tip_your_name").value;
	var your_email 	= document.getElementById("tip_your_mail").value;
	var your_msg 	= document.getElementById("tip_text").value;

	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation
	
	if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' || !her_email.match(re) || !your_email.match(re) ) {
	
		if (her_name == '' || her_email == '' || your_name == '' || your_email == '' || your_msg == '' ) {
			tip_friend_alertShow('missing');
		} 
		else {
			if (!her_email.match(re) && !your_email.match(re) ) {
			tip_friend_alertShow('both');
			}
			else {
				if (!her_email.match(re) ) {
				tip_friend_alertShow('her');
				} 
				else {
					if (!your_email.match(re) ) {
					tip_friend_alertShow('your');
					}	
				}
			}
		}
	}
	else { 
		your_msg=encodeURIComponent(your_msg);
		your_name=encodeURIComponent(your_name);
		her_name=encodeURIComponent(her_name);				
		var article_uuid = document.getElementById("article").value;
		var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
		var TopMenuSelected = document.getElementById("TopMenuSelected").value;
		var queryString = "TipForm_HerName=" + her_name + "&TipForm_HerMail=" + her_email + "&TipForm_YourName=" + your_name + "&TipForm_YourMail=" + your_email + "&TipForm_Text=" + your_msg + "&ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected;

		var myAjax = new Ajax.Updater("tip_friend_div", intershopPrefixPath+"cc_ViewArticleTipFriend-Create" , {method: 'post', parameters: queryString});	
		showSubmitionLoader(btn);

	}
	return false;
}




//--------------------------------------------------------
// Open "Create article comment" dialog window
//---------------------------------------------------------


function create_ArticleComment(article_uuid, Level4MenuSelected, TopMenuSelected, header) {

	// Hide flash video player, or it will hide the popup
	hideFlashVideo ();
		
	//var article_uuid = document.getElementById("article").value;
	//var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
	//var TopMenuSelected = document.getElementById("TopMenuSelected").value;
	Level4MenuSelected=encodeURIComponent(Level4MenuSelected);
	
	new LITBox(intershopPrefixPath+'cc_ViewArticleRating-New'+ "?ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected, {type:'window', overlay:true, height:320, width:420, resizable:true, opacity:1, header: header});
	return false;
}
//--------------------------------------------------------
// Send "Create article comment"
//---------------------------------------------------------
function create_comment_send(btn) {
	var name 	= document.getElementById("create_comment_name").value;
	var comment = document.getElementById("create_comment_comment").value;
	var check 	= document.getElementById("create_comment_confirm").checked;

	if( name == '' || comment == '')
		tip_friend_alertShow('missing');
		else if (check == '')
			tip_friend_alertShow('check');
			else {
			comment=encodeURIComponent(comment);
			name=encodeURIComponent(name);		
			var article_uuid = document.getElementById("article").value;
			var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
			var TopMenuSelected = document.getElementById("TopMenuSelected").value;
			var queryString = "RateForm_Name=" + name + "&RateForm_Confirm=" + check + "&RateForm_Comment=" + comment +"&ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected;
	//		var RefreshParameters = "ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected;
			
			var myAjax = new Ajax.Updater("article_div", intershopPrefixPath+"cc_ViewArticleRating-Create" , {method: 'post', parameters: queryString});
			showSubmitionLoader(btn);
	//		var CommentAjax = new Ajax.Updater("comments_refresh", "cc_ViewArticleRating-Refresh", {method: 'post', parameters: RefreshParameters});		
			}

	return false;
}

//--------------------------------------------------------
// Close "Create article comment"
//---------------------------------------------------------
function create_comment_close(btn) {
	var article_uuid = document.getElementById("article").value;
	var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
	var TopMenuSelected = document.getElementById("TopMenuSelected").value;
	var RefreshParameters = "ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected + "&TopMenuSelected=" + TopMenuSelected;
	var CommentAjax = new Ajax.Updater("comments_refresh", intershopPrefixPath+"cc_ViewArticleRating-Refresh", {method: 'post', parameters: RefreshParameters});
	return false;
}

//--------------------------------------------------------
// Open "Report comment abuse" Dialog Window
//---------------------------------------------------------
function report_ArticleCommentAbuse(triggerObj,article_uuid, Level4, Top, Name, Comment,header) {

	// Hide flash video player, or it will hide the popup
	hideFlashVideo ();
	
	Level4=encodeURIComponent(Level4);
	Name=encodeURIComponent(Name);
	//Comment=encodeURIComponent(Comment);
	new LITBox(triggerObj.href+ "?ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4 +"&TopMenuSelected=" + Top + "&Name=" + Name + "&Comment=" + Comment, {type:'window', overlay:true, height:320, width:440,  resizable:true, opacity:1, header: header});
	return false;
}
//--------------------------------------------------------
// Send "Report comment abuse" Dialog Window
//---------------------------------------------------------
function report_article_abuse_send(Name, Comment, triggerObj) {

	var AbuseForm_YourName 	= document.getElementById("tip_abuse_name").value;
	var AbuseForm_YourMail 	= document.getElementById("tip_abuse_mail").value;
	var AbuseForm_Text 	= document.getElementById("tip_abuse_text").value;
	
	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation
	
	if( AbuseForm_YourName == '' || AbuseForm_YourMail == '' || AbuseForm_Text == '' || !AbuseForm_YourMail.match(re) ) {
		if( AbuseForm_YourName == '' || AbuseForm_YourMail == '' || AbuseForm_Text == '') {
		tip_friend_alertShow('missing');
		}
		else {
		if (!AbuseForm_YourMail.match(re) ) {
			tip_friend_alertShow('your');
			}
		}
	} else{
		
		AbuseForm_Text=encodeURIComponent(AbuseForm_Text);
		AbuseForm_YourName=encodeURIComponent(AbuseForm_YourName);
		var article_uuid = document.getElementById("article").value;
		var Level4MenuSelected = document.getElementById("Level4MenuSelected").value;
		var TopMenuSelected = document.getElementById("TopMenuSelected").value;
		var queryString = "AbuseForm_YourName=" + AbuseForm_YourName + "&AbuseForm_YourMail=" + AbuseForm_YourMail + "&AbuseForm_Text=" + AbuseForm_Text + "&ArticleID=" + article_uuid + "&Level4MenuSelected=" + Level4MenuSelected +"&TopMenuSelected=" + TopMenuSelected + "&Name=" + Name + "&Comment=" + Comment;
		
		var myAjax = new Ajax.Updater("tip_abuse_div", intershopPrefixPath+"cc_ViewArticleAbuse-Create" , {method: 'post', parameters: queryString});	
		
		showSubmitionLoader(triggerObj);
	}

	return false;
}


//--------------------------------------------------------
// Paging of article Ratings
//---------------------------------------------------------
function paging_article(ArticleID, PageNumber) {

	var PagingParameters = "PageNumber_"+PageNumber+"=" + PageNumber +"&PageNumber=" + PageNumber +"&ArticleID=" + ArticleID;	
	
	var myAjax = new Ajax.Updater("comments_refresh", intershopPrefixPath+"cc_ViewArticle-Paging" , {method: 'post', parameters: PagingParameters});	
	

	return false;
}

//--------------------------------------------------------
// Open "Report comment abuse" Dialog
//---------------------------------------------------------
function report_ProductReviewAbuse(triggerObj,review_uuid, Name, Comment, header) {
	
	if ( !elementObjectExists('LitBox') ) {
		new LITBox(triggerObj.href +"?ProductUUID="+ review_uuid + "&Name=" + Name + "&Comment=" + Comment, {type:'window', overlay:true, height:320, width:420,  resizable:true, opacity:1, header: header});
	}
	
	return false;
}
//--------------------------------------------------------
// Send "Report comment abuse" Dialog
//---------------------------------------------------------
function report_review_abuse_send(ProductUUID, Name, Comment, triggerObj) {
	
	var name 	= document.getElementById("tip_name").value;
	var email	= document.getElementById("tip_mail").value;
	var text 	= document.getElementById("tip_text").value;
	
	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation
	
	if( name == '' || email == '' || text == '' || !email.match(re) ) {
		if( name == '' || email == '' || text == '') {
		tip_friend_alertShow('missing');
		}
		else {
		if (!email.match(re) ) {
			tip_friend_alertShow('your');
			}
		}
	} else{	
		//text=encodeURIComponent(text);
		//name=encodeURIComponent(name);		
		//var queryString = "AbuseForm_YourName=" + name + "&AbuseForm_YourMail=" + email + "&AbuseForm_Text=" + text + "&ProductUUID=" + ProductUUID + "&Name=" + Name + "&Comment=" + Comment;
		document.getElementById("abuse_product_id").value = ProductUUID;
		document.getElementById("abuse_comment").value = Comment;
		document.getElementById("abuse_name").value = name;
		var form = document.getElementById("form_tip_friend");
		//var queryString = Form.serialize(form);
		var queryString = $('form_tip_friend').serialize(true);
		var myAjax = new Ajax.Updater("product_abuse_div", intershopPrefixPath+"cc_ViewProductAbuse-Create" , {method: 'get', parameters: queryString});
		showSubmitionLoader(triggerObj);
	}
	return false;
}


//--------------------------------------------------------
// Open  "Create product review" dialog
//---------------------------------------------------------
function create_ProductReview(triggerObj, header) {	
	new LITBox(triggerObj.href, {type:'window', overlay:true, height:320, width:420, resizable:true, opacity:1, header: header, top:276});
	return false;
}

//--------------------------------------------------------
// Send "Create product review" 
//---------------------------------------------------------
function create_product_comment_send(btn) {
	var name 	= document.getElementById("create_comment_name").value;
	var comment = document.getElementById("create_comment_comment").value;
	var check 	= document.getElementById("create_comment_confirm").checked;

	if(comment.length>500){
		comment=cutToLongText(comment,500);
	}

	if( name == '' || comment == '')
		tip_friend_alertShow('missing');
		else if (check == '')
			tip_friend_alertShow('check');
			else {
				//comment=encodeURIComponent(comment);
				//name=encodeURIComponent(name);		
				var ProductUUID = document.getElementById("ProductUUID").value;
				document.getElementById("rating_product_id").value = ProductUUID;
				var form = document.getElementById("f1");
				var queryString = Form.serialize(form);
				//form.submit();
				
				
				//var queryString = "RateForm_Name=" + name + "&RateForm_Confirm=" + check + "&RateForm_Comment=" + comment +"&ProductUUID=" + ProductUUID;			
				//var RefreshParameters = "ProductUUID=" + ProductUUID;	
				var myAjax = new Ajax.Updater("article_div", btn.href , {method: 'get', parameters: queryString});
				//	var RatingAjax = new Ajax.Updater("comments_refresh", "cc_ViewProductRating-Refresh", {method: 'post', parameters: RefreshParameters});
				showSubmitionLoader(btn);
				
			}
	return false;
}

//--------------------------------------------------------
// Close "Create product comment"
//---------------------------------------------------------
function create_product_comment_close(btn) {
	var product_uuid = document.getElementById("ProductUUID").value;
	var RefreshParameters = "ProductUUID=" + product_uuid;
	var CommentAjax = new Ajax.Updater("ratings_refresh", intershopPrefixPath+"cc_ViewProductRating-Refresh", {method: 'post', parameters: RefreshParameters});
	return false;
}

//--------------------------------------------------------
// (Paging of Product Ratings is located in product.js)
//---------------------------------------------------------



//--------------------------------------------------------
// open "Contact shop owner" dialog
//---------------------------------------------------------
function contact_ShopOwner(header) {
	var ShopUUID = document.getElementById("ShopUUID").value;
	new LITBox('cc_UserShop-ContactOwner'+ '?ShopUUID=' + ShopUUID, {type:'window', overlay:true, height:320, width:420, resizable:true, opacity:1, header: header});
	return false;
}
//--------------------------------------------------------
// SEND "Contact shop owner" 
//---------------------------------------------------------
function contact_shop_send(btn){
	var her_name 	= document.getElementById("InvitationForm_FriendName").value;
	var her_email	= document.getElementById("InvitationForm_MailTo").value;
	var your_name	= document.getElementById("InvitationForm_Message").value;	
	
	// RegExp for mailadres validation (cjecks even the end of adress ex. ".s" or ".se")
	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation	

	

	if (her_name == '' || her_email == '' || your_name == ''){
		tip_friend_alertShow('missing');
	}
	else if (!her_email.match(re)) {
		tip_friend_alertShow('her');
	} else {
		your_name=encodeURIComponent(your_name);
		her_name=encodeURIComponent(her_name);		
		if(document.getElementById("InvitationForm_MailSelf")){
			if(document.getElementById("InvitationForm_MailSelf").checked){
				var your_email	= document.getElementById("InvitationForm_MailSelf").value;	
			}
		}
		var ShopUUID = document.getElementById("ShopUUID").value;
		var queryString = "InvitationForm_FriendName=" + her_name + "&InvitationForm_MailTo=" + her_email + "&InvitationForm_Message=" + your_name+"&InvitationForm_MailSelf=" + your_email+"&ShopUUID="+ShopUUID;
		var myAjax = new Ajax.Updater("tip_friend_div", "cc_UserShop-ContactOwnerSend" , {method: 'post', parameters: queryString});			
		showSubmitionLoader(btn);

	}
	return false;
}






function report_ShopAbuse(header) {
	var ShopUUID = document.getElementById("ShopUUID").value;
	var ShopName = document.getElementById("ShopName").value;
	ShopUUID=encodeURIComponent(ShopUUID);	
	ShopName=encodeURIComponent(ShopName);
	new LITBox('cc_UserShop-AbuseReport'+ '?ShopUUID=' + ShopUUID +'&ShopName='+ShopName, {type:'window', overlay:true, height:290, width:420,  resizable:true, opacity:1, header: header});
	return false;
}

//--------------------------------------------------------
// Send "Report shop abuse" 
//---------------------------------------------------------
function report_shop_abuse_send(btn){
	var AbuseForm_YourName 	= document.getElementById("tip_abuse_name").value;
	var AbuseForm_YourMail 	= document.getElementById("tip_abuse_mail").value;
	var AbuseForm_Text 	= document.getElementById("tip_abuse_text").value;

	
	var re = /^[0-9a-zA-Z_\-]+[0-9a-zA-Z\._\-]*@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z\._\-]*[0-9a-zA-Z_\-]{2,}$/;  //Email validation

	if( AbuseForm_YourName == '' || AbuseForm_YourMail == '' || AbuseForm_Text == '' || !AbuseForm_YourMail.match(re) || AbuseForm_Text.fulltrim().length == 0) {

		if( AbuseForm_YourName == '' || AbuseForm_YourMail == '' || AbuseForm_Text == '' || AbuseForm_Text.fulltrim().length == 0 ) {
			tip_friend_alertShow('missing');
		}
		else {
			if (!AbuseForm_YourMail.match(re) ) {
				tip_friend_alertShow('your');
			}
		}

	} else{
		AbuseForm_Text=encodeURIComponent(AbuseForm_Text);
		AbuseForm_YourName=encodeURIComponent(AbuseForm_YourName);
		var ShopUUID = document.getElementById("ShopUUID").value;
		var ShopName = document.getElementById("ShopName").value;		
		var queryString = "AbuseForm_YourName=" + AbuseForm_YourName + "&AbuseForm_YourMail=" + AbuseForm_YourMail + "&AbuseForm_Text=" + AbuseForm_Text + "&ShopUUID=" + ShopUUID + "&ShopName=" + ShopName;
		
		var myAjax = new Ajax.Updater("tip_abuse_div", "cc_UserShop-AbuseReportSend" , {method: 'post', parameters: queryString});	
		showSubmitionLoader(btn);
	}
	return false;
}

//--------------------------------------------------------
// Hides flash video element: use when opening a litbox
//--------------------------------------------------------
function hideFlashVideo () {
	// Hide flash video player, or it will hide the popup
	if( document.getElementById("StadiumVideoViewer") ) {
		document.getElementById("StadiumVideoViewer").style.visibility = "hidden";
	}
}









