
var kwm_rating = 5;

function showThankyou(name){
	if(navigator.appName.indexOf("Microsoft")!=-1){
		window_width = document.documentElement.clientWidth;
		window_height = document.documentElement.clientHeight;
	}else{
		window_width = window.innerWidth;
		window_height = window.innerHeight;
	}
	
	w_left = (window_width/2) - 200;
	w_top = (window_height/2) - 200;
	
	window.open(name+".html", null, "height=400,width=400,left="+w_left+",top="+w_top);
	
}

function setValue(option, rating){

	switch(rating)
	{
	case 1:
	  rating_str = 'one'
	  break;    
	case 2:
	  rating_str = 'two'
	  break;
	case 3:
	  rating_str = 'three'
	  break;    
	case 4:
	  rating_str = 'four'
	  break;
	case 5:
	  rating_str = 'five'
	  break;
	}
	
	if(option == 'kwm_rating'){
		kwm_rating = rating;
		document.getElementById('kwm_rating').className = 'rating '+rating_str+'star';
	}
	
}

var pPath = window.location.pathname;
var pPage = pPath.substring(pPath.lastIndexOf('/') + 1)
var http_request = false;
var loadingStr = '<img src="http://www.kingwebtools.com/madison_art_shop/feedback_system/images/ajax-loader.gif" />'

function SubmitReview() {
	var jsel = document.createElement('SCRIPT');
	var rating = kwm_rating;
	jsel.type = 'text/javascript';
	jsel.src = 'http://www.kingwebtools.com/madison_art_shop/feedback_system/submit_review.php?item_id=' + encodeURI( document.getElementById("kwm_item_id").value ) + '&kwm_comment=' + encodeURI( document.getElementById("kwm_comment").value ) + '&your_name=' + encodeURI( document.getElementById("your_name").value ) + '&your_location=' + encodeURI( document.getElementById("your_location").value ) + '&item_name=' + encodeURI( document.getElementById("item_name").value ) + '&rating=' + encodeURI( rating ) + '&your_location=' + encodeURI( document.getElementById("your_location").value );
	
	document.getElementById('submit_review_form').innerHTML = loadingStr;
	document.getElementById('submit_review_form').appendChild (jsel);
	
	showThankyou('reviewconfirm');
	
	document.getElementById('submit_review_form').style.display = 'none';
}

function SubmitQuestion() {
	if(document.getElementById("your_question").value != ""){
		if(checkEmail(document.getElementById("q_email").value)){
			var jsel = document.createElement('SCRIPT');
			jsel.type = 'text/javascript';
			jsel.src = 'http://www.kingwebtools.com/madison_art_shop/feedback_system/submit_question.php?item_id=' + encodeURI( document.getElementById("kwm_qitem_id").value ) + '&your_question=' + encodeURI( document.getElementById("your_question").value ) + '&q_email=' + encodeURI( document.getElementById("q_email").value );
		
			document.getElementById('submit_question_form').innerHTML = '<img src="http://lib.store.yahoo.net/lib/gamesusainc/ajax-loader.gif" />';
			document.getElementById('submit_question_form').appendChild (jsel);
		}else{
			alert("You need to type in correct email address!");
			document.getElementById("q_email").focus();			
		}
    }else{
		alert("You need to type in the question!");
		document.getElementById("your_question").focus();
	}
}

function checkEmail(e){
   
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     
	if (e.search(emailRegEx) == -1) {
         return false;
    }else{
         return true;
    }

}


//display hide reviews
function dhReviews(eId){
	it = document.getElementById(eId);
	
	if(document.getElementById('more_reviews').style.display == 'none'){
		it.innerHTML = 'Hide Reviews';
		document.getElementById('more_reviews').style.display = '';
	}else{
		it.innerHTML = 'View All Reviews ...';
		document.getElementById('more_reviews').style.display = 'none';	
	}
}

//display hide questions and answers
function dhQuestions(eId){
	it = document.getElementById(eId);
	
	if(document.getElementById('more_qa').style.display == 'none'){
		it.innerHTML = 'Hide Q & A';
		document.getElementById('more_qa').style.display = '';
	}else{
		it.innerHTML = 'View All Q & A ...';
		document.getElementById('more_qa').style.display = 'none';	
	}
}

function showrev()	{
	document.getElementById('addrev').style.display = 'block';
	document.getElementById('viewall').style.display = 'none';
	document.getElementById('hideall').style.display = 'block';
}

function hiderev()	{
	document.getElementById('addrev').style.display = 'none';
	document.getElementById('viewall').style.display = 'block';
	document.getElementById('hideall').style.display = 'none';
}