
function swf(fn){
	var w=425;
	var h=344;
	document.write("<object width=\""+w+"\" height=\""+h+"\"><param name=\"movie\" value=\""+fn+"\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\""+fn+"\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\""+w+"\" height=\""+w+"\"></embed></object><br>");
	
}

function related_url(vid){
	if(ge(vid).style.display=='none'){
		ge(vid).style.display='';
	}else{
		ge(vid).style.display='none';
	}
}

function check_post(){
	var is_ok=false;
	var is_reg=true;
if(document.pf.register && document.pf.register.checked){
	is_reg=false;
	if(document.pf.Name.value==""){
		alert("Please enter Your Name to Register!");
		document.pf.Name.focus();	
		return false;
	}else if(document.pf.Email.value==""){
		alert("Please enter Your Email to Register!");
		document.pf.Email.focus();	
		return false;
	}else{
		is_reg=true;
	}
}
	//if(document.pf.Name.value==""){
	//	alert("Please enter Your Name!");
	//	document.pf.Name.focus();	
	//}
	//else if(document.pf.Email.value==""){
	//	alert("Please enter Your Email!");
	//	document.pf.Email.focus();	
	//}
	if(document.pf.Contents.value==""){
		alert("Please enter Your Comment!");
		document.pf.Contents.focus();	
	}else if(document.pf.authcode.value==""){
		alert("Please enter Auth Code!");
		document.pf.authcode.focus();	
	}else{
		is_ok=true;
	}
	if(is_reg!=true){
		is_ok=false;
	}
	return is_ok;
}


function chk_submit(){
	var is_ok=false;
	var is_reg=true;
if(document.haircutrv.register && document.haircutrv.register.checked){
	is_reg=false;
	if(document.haircutrv.Name.value==""){
		alert("Please enter Your Name to Register!");
		document.haircutrv.Name.focus();	
		return false;
	}else if(document.haircutrv.Email.value==""){
		alert("Please enter Your Email to Register!");
		document.haircutrv.Email.focus();	
		return false;
	}else{
		is_reg=true;
	}
}
	if(document.haircutrv.Title.value==""){
		alert("Please enter Review Title!");
		document.haircutrv.Title.focus();
	}else if(!document.haircutrv.Rating_All[0].checked && !document.haircutrv.Rating_All[1].checked && !document.haircutrv.Rating_All[2].checked && !document.haircutrv.Rating_All[3].checked && !document.haircutrv.Rating_All[4].checked){
		alert("Please Select a Rating!");
		document.haircutrv.Rating_All[0].focus();	
	}
	//else if(document.haircutrv.Name.value==""){
	//	alert("Please enter Your Name!");
	//	document.haircutrv.Name.focus();	
	//}
	//else if(document.haircutrv.Email.value==""){
	//	alert("Please enter Your Email!");
	//	document.haircutrv.Email.focus();	
	//}
	else if(document.haircutrv.Contents.value==""){
		alert("Please enter Full Review!");
		document.haircutrv.Contents.focus();	
	}else if(document.haircutrv.authcode.value==""){
		alert("Please enter Auth Code!");
		document.haircutrv.authcode.focus();	
	}else{
		is_ok=true;
	}
	if(is_reg!=true){
		is_ok=false;
	}
	return is_ok;
}

function p2b(pid,mid){
	if(document.getElementById("tt_"+pid+"_"+mid).style.display=='none'){
	var at=document.getElementById(pid+"name"+mid).innerHTML;
	var ct=document.getElementById(pid+"msg"+mid).innerHTML;
	ct = ct.replace(/<div class=\"fieldset\">Quote:<div class=\"legend\">(.+)<\/div><\/div>(.+)/gim,"$2");
	ct = ct.replace(/<br>/ig,"");
	document.getElementById(pid+'_tt_'+mid).value=at+' said: '+ct+' <br>more detail: '+document.location.href;
	document.getElementById("tt_"+pid+"_"+mid).style.display='';
	
	var pconf={
      defaultContent: pid+'_tt_'+mid,
      UIConfig: '<config><display showBookmark="true" showEmail="true" /></config>'
    };
    Wildfire.initPost('236561', 'divWildfirePost_'+pid+"_"+mid, 400, 300, pconf);
	}else{
		document.getElementById("tt_"+pid+"_"+mid).style.display='none';
	}
}

function quoteit(pid,mid){
	var trg=document.haircutrv.Contents.value;
	if(document.haircutrv.Contents){
		if(trg.match(/\[quote=/i)){
		}else{
			var at=document.getElementById(pid+"name"+mid).innerHTML;
			var ct=document.getElementById(pid+"msg"+mid).innerHTML;
			ct = ct.replace(/<div class=\"fieldset\">Quote:<div class=\"legend\">(.+)<\/div><\/div>(.+)/gim,"$2");
			ct = ct.replace(/<br>/ig,"");
			document.haircutrv.Contents.value="[quote="+at+"]"+ct+"[/quote]"+trg;
			document.haircutrv.Contents.focus();
		}
	}
}

function quoteit2(pid,mid){
	var trg=document.pf.Contents.value;
	if(document.pf.Contents){
		if(trg.match(/\[quote=/i)){
		}else{
			var at=document.getElementById(pid+"name"+mid).innerHTML;
			var ct=document.getElementById(pid+"msg"+mid).innerHTML;
			ct = ct.replace(/<div class=\"fieldset\">Quote:<div class=\"legend\">(.+)<\/div><\/div>(.+)/gim,"$2");
			ct = ct.replace(/<br>/ig,"");
			document.pf.Contents.value="[quote="+at+"]"+ct+"[/quote]"+trg;
			document.pf.Contents.focus();
		}
	}
}

function thumbit(pid,rid,rs){
var post="id="+pid+"&vote="+rid+"&"+rs+"=1";
rspid="rsp_"+pid+"_"+rid;
makePost2('/ajax_ishelpful.php', post, "alertContents2");
}
function alertContents2() {
ge(rspid).innerHTML= "<img src='/images/loading.gif' align=absmiddle> Wait...";
      if (http_request.readyState == 4) {
      	 if (http_request.status == 200) {
            var result = http_request.responseText;
            ge(rspid).innerHTML=result;
            setTimeout(function(){ge(rspid).innerHTML="";}, 1000);
         } else {
            alert('There was a problem with the request. ['+http_request.status+']');
         }
      }
}

function pthumbu(pid,rs){
var post="id="+pid+"&"+rs+"=1";
rspid2="pthumbu_result_"+pid;
makePost2('/ajax_thumbu.php', post, "alertContents_tm");
}

function pthumb(pid,rs){
var post="id="+pid+"&"+rs+"=1";
rspid2="pthumb_result_"+pid;
makePost2('/ajax_thumb.php', post, "alertContents_tm");
}

function upthumb(pid,rs){
var post="id="+pid+"&"+rs+"=1";
rspid2="upthumb_result_"+pid;
makePost2('/ajax_thumb_u.php', post, "alertContents_tm");
}


function alertContents_tm() {
ge(rspid2).innerHTML= "<img src='/images/loading.gif' align=absmiddle> Wait...";
      if (http_request.readyState == 4) {
      	 if (http_request.status == 200) {
            var result = http_request.responseText;
            ge(rspid2).innerHTML=result;
            setTimeout(function(){ge(rspid2).innerHTML="";}, 1000);
         } else {
            alert('There was a problem with the request. ['+http_request.status+']');
         }
      }
}

function comment_style(f,img){
	if(img.match(/\.(gif|jpg)$/i)){
	var obj=ge(f);
	if(!ge("style_img")){
		div = document.createElement('div');
		div.id="style_img";
		div.className="style_img";
		obj.appendChild(div);
	    div.innerHTML="<img src=\""+img+"\">";
    }else{
    	ge("style_img").style.display='';
    }	
    }
}

//onBlur
function comment_style_done(f){
	if(ge("style_img")){
		//ge("style_img").style.display='none';
		//interval = setInterval("delv(\""+obj.name+"\");", 1000);
    }
    //
}

function delv(ff){
	var obj=eval("document."+ff);
	obj.removeChild(div);
	if(interval != null){
		clearInterval(interval);
		interval = null;
	}
}

var star1= new Image(10,10); 
star1.src="http://www.prohaircut.com/images/rating_bad.gif";
var star2= new Image(10,10); 
star2.src="http://www.prohaircut.com/images/rating_poor.gif";
var star3= new Image(10,10); 
star3.src="http://www.prohaircut.com/images/rating_average.gif";
var star4= new Image(10,10); 
star4.src="http://www.prohaircut.com/images/rating_good.gif";
var star5= new Image(10,10); 
star5.src="http://www.prohaircut.com/images/rating_excellent.gif";

function showstar(f,img){
	ge('starshow').innerHTML="<img src=\"/images/"+img+"\">";
	ge("starshow").style.display='';
	f.style.background='#FEF1A4';
}

function hidestar(f){
	f.style.background='#FFFFFF';
	if(ge("starshow")){
		ge("starshow").style.display='none';
    }	
}

function slider(container, frequency, direction) {
	if (typeof(container) == 'string') {
		container = document.getElementById(container);
	}
	this.container = container;
	this.frequency = frequency;
	this.direction = direction;
	this.films = [];
	if(this.container){
		var divs = this.container.getElementsByTagName('div');
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].className == 'hc') {
				divs[i].onmouseover = function(self){return function(){self._mouseover()};}(this);
				divs[i].onmouseout = function(self){return function(){self._mouseout()};}(this);
				this.films[this.films.length] = divs[i];
			}
		}
		this._playTimeoutId = null;
		this._slideTimeoutId = null;
		this._slidable = true;
	
		this._loop();
	}
}

slider.prototype = {
	_loop : function() {
		var sb = this;
		this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency);
	},

	_slide : function() {
		var sb = this;
		var _slide = function() {
			if (!sb._slidable) return;
			var c = sb.container;
			if (sb.direction == 'top') {
				if (c.scrollTop < c.offsetHeight-2) {
					c.scrollTop += 2;
				} else {
					clearInterval(sb._slideTimeoutId);
					sb._loop();
					var ul = c.getElementsByTagName('ul')[0];
					ul.appendChild(c.getElementsByTagName('li')[0]);
					c.scrollTop = 0;
				}
			} else if (sb.direction == 'left') {
				if (c.scrollLeft < c.offsetWidth-2) {
					c.scrollLeft += 2;
				} else {
					clearInterval(sb._slideTimeoutId);
					sb._loop();
					var ul = c.getElementsByTagName('ul')[0];
					ul.appendChild(c.getElementsByTagName('li')[0]);
					c.scrollLeft = 0;
				}
			} else if (sb.direction == 'transparent') {
			
				if (c.style.opacity <= 1 && c.style.opacity>0) {
					c.style.opacity -= 0.25;
				} else {
					clearInterval(sb._slideTimeoutId);
					sb._loop();
					c.style.opacity = 1;
				}
			}
		}
		this._slideTimeoutId = setInterval(_slide, 10);
	},

	_mouseover : function() {
		this._slidable = false;
	},

	_mouseout : function() {
		this._slidable = true;
	}
}

function showTools(id,kid,mid) {
	var el = ge(id);
	var pp = ge(kid);
	var bb=ge(mid);
	if(el.className == 'buryshare') {
		el.className = 'drillshare'
		var mew=get_vplace(pp);
		mev=mew[0]+1;
		meT=mew[1];
		var met=meS( );
		var mes=meR( );
		var temp=meT-mes[1]+bb.clientHeight+52;
		var temp2=met[1];
		var chk_v=parseInt(temp) - parseInt(temp2);
		if( chk_v >= 0){
			bb.style.top='0px';
			if(document.all){
				bb.style.top='-'+(bb.clientHeight+19)+'px'; 
			}else{
				bb.style.top='-'+(bb.clientHeight+18)+'px'; 
			}
		}else{
			if(document.all){
				bb.style.top='-5px';
			}else{
				bb.style.top='-10px';
			}
		}
	};
}

function rmTools(id) {
	var el = ge(id);
	if(el.className == 'drillshare') {el.className = 'buryshare'};
}

function addfav(mURL,mTitle){
	my_url=decodeURIComponent(mURL); 
	my_title=decodeURIComponent(mTitle); 
	if (document.all)window.external.AddFavorite(my_url,my_title); 
	else window.sidebar.addPanel(my_title,my_url,''); 
	return false; 	
}

function get_vplace(t){
		var meq=0,meP=0; 
		do {meq+=t.offsetTop || 0; meP+=t.offsetLeft || 0; t=t.offsetParent; }while (t); 
		return [meP,meq]; 
	}

function meS( ){
		var mep=0; 
		var meN=0; 
		if (typeof(window.innerWidth)=='number'){
			mep=window.innerWidth; 
			meN=window.innerHeight; 
		}else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
			mep=document.documentElement.clientWidth; 
			meN=document.documentElement.clientHeight; 
		}else if (document.body && (document.body.clientWidth || document.body.clientHeight)){
			mep=document.body.clientWidth; meN=document.body.clientHeight; 
		}
		return [mep,meN]; 
}

function meR( ){
		var men=0; 
		var meM=0; 
		if (typeof(window.pageYOffset)=='number'){
			meM=window.pageYOffset; 
			men=window.pageXOffset; 
		}else if (document.body && (document.body.scrollLeft || document.body.scrollTop)){
			meM=document.body.scrollTop; men=document.body.scrollLeft; 
		}else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
			meM=document.documentElement.scrollTop; 
			men=document.documentElement.scrollLeft; 
		}
		return [men,meM]; 
}

//////////////////////////////////
var rv_cp=1;
function paging(pid,page){
rv_cp=page;
var post="area=comment&pid="+pid+"&cp="+page+"";
post=post+"&url="+document.location.href+"&title="+escape(document.title)+"&";
rspid="paging_result_"+pid;
makePost2('/ajax_paging.php', post, "ajax_paging");
}
function ajax_paging() {
	var current_num=parseInt(ge("current_num").innerHTML);
	for(var i=0;i<=current_num;i++){
		if(ge("list_"+i) && ge("list_"+i).style.display==""){
			ge("list_"+i).style.display="none";	
		}
	}
	ge(rspid).innerHTML= "<img src='/images/loading.gif' align=absmiddle> Wait...Loading...";
      if (http_request.readyState == 4) {
      	 if (http_request.status == 200) {
            var result = http_request.responseText;
            var myData = json_parse(result);
            if(myData.err){
            	ge(rspid).innerHTML=myData.err;
            }else{
            	var rt_data="";
	            
	            for(var t=0;t<myData.length;t++){
	            	//ge(rspid).innerHTML+="<div align=\"left\">["+(t+1)+"]<b>"+myData[t].title+"</b><br><i><small>"+myData[t].date+", by <b class=\"name\">"+myData[t].name+"</b></small></i><div >"+myData[t].review+"</div></div>";
	            	
	            	var rate_img="rating_excellent.gif";
					if(myData[t].rating.match(/^4\./)){
						rate_img="rating_good.gif";
					}else if(myData[t].rating.match(/^3\./)){
						rate_img="rating_average.gif";
					}else if(myData[t].rating.match(/^2\./)){
						rate_img="rating_poor.gif";
					}else if(myData[t].rating.match(/^1\./)){
						rate_img="rating_bad.gif";
					}
					var user='<b class="name">'+myData[t].name+'</b>';
					if(myData[t].vid!=""){
						user='<a href="/profile.php?u='+myData[t].vid+'"><b class="name">'+myData[t].name+'</b></a>';
					}
					rt_data+='<tr><td colspan="2" style="border-top:1px #efefef solid;">';
					rt_data+='<a name="'+myData[t].pid+'_'+myData[t].rate_id+'"></a>';
					rt_data+='<div class="myicon"><img src="'+myData[t].icon+'"></div>';
					rt_data+='<img src="/images/'+rate_img+'" align="absmiddle" alt="Rating: '+myData[t].rating+'" border="0">';
					rt_data+='<b>'+myData[t].title+'</b> ';
					rt_data+='<br><i><small>'+myData[t].date+', by <span id="'+myData[t].pid+'name'+myData[t].rate_id+'">'+user+'</span></small></i>';
					rt_data+='<div id="'+myData[t].pid+'msg'+myData[t].rate_id+'" style="padding:3px;font: 105%/1.2em Arial, Helvetica, sans-serif;">'+myData[t].review+'</div>';
					//rt_data+='<script src="http://cdn.gigya.com/wildfire/js/wfapiv2.js"></script>';
					rt_data+='<div class="thumb">';
					rt_data+='<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0"><tr><td align="center" class="thumb_l">';
					rt_data+=''+myData[t].rate_yes+' <a rel="nofollow" onclick="javascript: thumbit(\''+myData[t].pid+'\',\''+myData[t].rate_id+'\',\'yes\');" href="javascript:void(0);"><img alt="Thumb this up!" align="absmiddle" src="/images/yes.gif" border="0"></a></td><td align="center" class="thumb_l"> | </td><td align="center" class="thumb_l">';
					rt_data+=''+myData[t].rate_no+' <a rel="nofollow" onclick="javascript: thumbit(\''+myData[t].pid+'\',\''+myData[t].rate_id+'\',\'no\');" href="javascript:void(0);"><img alt="Thumb this down!" align="absmiddle" src="/images/no.gif" border="0"></a></td><td align="center" class="thumb_l"> | </td><td align="center" class="thumb_l">';
					rt_data+='<a href="javascript:void(0);" onclick="javascript:quoteit(\''+myData[t].pid+'\',\''+myData[t].rate_id+'\');">Quote</a>';
					rt_data+='</td><td align="center" class="thumb_l"> | </td>';
					rt_data+='<td align="center" class="thumb_l">';
					rt_data+='<a href="javascript:void(0);" onclick="javascript:p2b(\''+myData[t].pid+'\',\''+myData[t].rate_id+'\');">Post to Blogs</a>';
					rt_data+='</td></tr></table></div>';
					rt_data+='<div id="tt_'+myData[t].pid+'_'+myData[t].rate_id+'" style="display:none;">';
					rt_data+='<center><b>Post this to Blogs</b><br />';
					rt_data+='<textarea rows="1" cols="1" id="'+myData[t].pid+'_tt_'+myData[t].rate_id+'" style="display: none"></textarea>';
					rt_data+='<div id="divWildfirePost_'+myData[t].pid+'_'+myData[t].rate_id+'"></div></center></div>';
					rt_data+='<div id="rsp_'+myData[t].pid+'_'+myData[t].rate_id+'"></div></td></tr>';
	            	
				}
				ge(rspid).innerHTML=rt_data;
				
				if(ge('current_page')){
					ge('current_page').innerHTML=rv_cp;	
				}
				
				if(ge('current_page2')){
					ge('current_page2').innerHTML=rv_cp;		
				}
				
			}
         } else {
            alert('There was a problem with the request. ['+http_request.status+']');
         }
      }
}


function myopenWin(img){
  if(img.match(/\.(jpg|gif|png)$/i)){
    window.open(img,'','scrollbars=yes,menubar=no,height=600,width=650,resizable=yes,toolbar=no,location=no,status=no');   
  }
}


