

var SVP="http://www.loadzy.com/";

var tb_pathToImage = SVP+"common/images/loadingAnimation.gif";



function do_left_srch()

{

	if(this.document.frm_left_srch.srch_str.value=="")

	{

		alert("Please enter the search string");

		return false;

	}

	document.frm_left_srch.action=SVP+"search/"+this.document.frm_left_srch.srch_str.value+"/";

	document.frm_left_srch.submit();

}

function frm_login_top(r_false)

{

		if(this.document.frm_login.mem_username.value=="" || this.document.frm_login.mem_username.value=="Username" || this.document.frm_login.mem_password.value=="" ||  this.document.frm_login.mem_password.value=="Password")



	{

		alert("Please enter your Username & Password to login");

		if(r_false==1)

		{

			return false;

		}

	}

	else

	{

		this.document.frm_login.submit();

		if(r_false==1)

		{

			return false;

		}

	}

}

function frm_login_main_chk(r_false)

{

		if(this.document.frm_login_main.mem_username.value==""  || this.document.frm_login.mem_password.value=="")



	{

		alert("Please enter your Username & Password to login");

		if(r_false==1)

		{

			return false;

		}

	}

	else

	{

		this.document.frm_login_main.submit();

		if(r_false==1)

		{

			return false;

		}

	}

}



function frm_password_chk()

{ 

	var obj=this.document.frm_password.forgot_email;

	if(obj.value=="")

	{

		alert("Please enter your email address");

		return false;

	}

	if(!validateEmail(obj.value))

	{

		alert("Please enter your vaild email address");

		return false;

	}

}



function fav_ip_add(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_add&s_type=ip&s_id="+a;

}

function fav_ip_del(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_del&s_type=ip&s_id="+a;

}

function my_fav_ip_del(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_del&s_type=ip&s_id="+a+"&output=1";

}

function my_fav_icon_del(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_del&s_type=icon&s_id="+a+"&output=1";

}

function fav_icon_del(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_del&s_type=icon&s_id="+a;

}

function fav_icon_add(a)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"mem_fav.php?act=mf_add&s_type=icon&s_id="+a;

}



function rating_default()

{

	document.getElementById('js_rate_main').style.display="";

	document.getElementById('js_rate_do').style.display="none";

}

function rating_show()

{

	document.getElementById('js_rate_main').style.display="none";

	document.getElementById('js_rate_do').style.display="";

}

function rating_do(s_id,s_type,rating)

{

	ctrl=document.getElementById('ifr_nee');

	ctrl.src=SVP+"index.php?act=rating_do&rat_s_id="+s_id+"&rat_s_type="+s_type+"&rat_rating="+rating;

}

function rating_set(a)

{	

	document.getElementById('r_1_').src=SVP+"common/images/rating_"+a+".gif";

	document.getElementById('js_rate_main').style.display="";

	document.getElementById('js_rate_do').style.display="none";

}

function rating_out(id)

{

	for(i=1;i<=5;)

	{

		if(i<=id)

		{

			id_=document.getElementById('r_'+i);

			if(id_)

			{

				id_.src=SVP+"common/images/star_0.gif";

			}

		}

		i++;

	}

	rating_default();

}

function rating_over(id)

{

	for(i=1;i<=5;)

	{

		if(i<=id)

		{

			id_=document.getElementById('r_'+i);

			if(id_)

			{

				id_.src=SVP+"common/images/star_1.gif";

			}

		}

		i++;

	}

}

function frm_chk_signup()

{

	t=this.document.frm_signup;

	if(t.mem_username.value=="" || t.mem_email.value=="" || t.mem_password.value=="" || t.mem_cpassword.value=="" )

	{

		alert("Please fill all * marked fields to proceed");

		return false;

	}

	if(!validateEmail(t.mem_email.value))

	{

		alert("Please enter your vaild email address");

		return false;

	}

	if(t.mem_type[0].checked==false && t.mem_type[1].checked==false)

	{

		alert("Please select the member type.");

		return false;

	}

	if(t.mem_password.value!=t.mem_cpassword.value)

	{

		alert("Password and Verify Password do not matched");

		return false;

	}

	if(t.captcha.value=="")

	{

		alert("Please enter the Security Code");

		return false;

	}

	if(!t.terms.checked)

	{

		alert("Please select the checked to accept our Terms of Service to proceed");

		return false;

	}

}



function chk_profle()

{

	t=this.document.frm_profile;

	if(t.mem_name.value=="" || t.mem_cl_id.value=="-1" )

	{

		alert("Please fill all * marked fields to proceed.");

		return false;

	}

	t.submit();

}



function show_editor(a)

{

  this.document.getElementById("get_about_us").value=a;

  if(a==1)

  {

	this.document.getElementById("about_editor").style.display="";

	this.document.getElementById("about_text").style.display="none";

  }else{

	this.document.getElementById("about_editor").style.display="none";

	this.document.getElementById("about_text").style.display="";

  }

}



function chk_profle_pass()

{

	t=this.document.frm_profile_pass;

	if(t.mem_password.value=="")

	{

		alert("Please enter the old password");

		return false;

	}

	if(t.mem_npassword.value=="")

	{

		alert("Please enter the new password");

		return false;

	}

	if(t.mem_password.value!="" && t.mem_npassword.value!="" && t.mem_ncpassword.value=="")

	{

		alert("Please enter the new confirm password");

		return false;

	}

	if(t.mem_npassword.value!=t.mem_ncpassword.value)

	{

		alert("New password and confirm password do not matched");

		return false;

	}	

	t.submit();

}





function chk_profle_img()

{

	t=this.document.frm_profile_img;

	if(t.mem_avatar.value=="")

	{

		alert("Please choose your image to upload.");

		return false;

	}

	t.submit();

}



function chk_post_comment()

{

	t=this.document.frm_comment;

	if(t.com_comment.value=="" )

	{

		alert("Please enter your comment.");

		return false;

	}

	if(t.com_captcha.value=="")

	{

		alert("Please enter the the security code.");

		return false;

	}

	if(t.com_s_type.value=="profile")

	{

		t.act.value="profile_comment_save";	

	}else if(t.com_s_type.value=="ip")

	{

		t.act.value="ip_comment_save";	

	}else{

		t.act.value="icon_comment_save";		

	}

	return true;

}



function edit_comment(a)

{

	var path=SVP;

	t=this.document.frm_comment;

	if(t.com_s_type.value=="profile")

	{

		path=SVP+"author_profile.php?act=profile_comment_edit&com_id="+a+"&width=750&height=320";	

	}else if(t.com_s_type.value=="ip")

	{

		path=SVP+"ip.php?act=ip_comment_edit&com_id="+a+"&width=750&height=320";	

	}else{

		path=SVP+"icon.php?act=icon_comment_edit&com_id="+a+"&width=750&height=320";		

	}

	tb_show("<b>Loadzy</b>",path,"");

}



function chk_update_comment()

{

	t=this.document.frm_update_comment;

	if(t.com_comment.value=="" )

	{

		alert("Please enter your comment.");

		return false;

	}

	if(t.com_captcha.value=="")

	{

		alert("Please enter the the security code.");

		return false;

	}

	if(t.com_s_type.value=="profile")

	{

		t.act.value="profile_comment_update";	

	}else if(t.com_s_type.value=="ip")

	{

		t.act.value="ip_comment_update";	

	}else{

		t.act.value="icon_comment_update";		

	}

	

	return true;

}



function delete_comment(a)

{

	t=this.document.frm_comment;

	if(confirm("Are you sure to delete this comment."))

	{

		t.com_id.value=a;

		if(t.com_s_type.value=="profile")

		{

			t.act.value="profile_comment_delete";	

		}else if(t.com_s_type.value=="ip")

		{

			t.act.value="ip_comment_delete";	

		}else{

			t.act.value="icon_comment_delete";		

		}

		t.submit();

	}

	

}



function report_comment(a)

{

	t=this.document.frm_comment;

		t.com_id.value=a;

		if(t.com_s_type.value=="profile")

		{

			t.act.value="profile_comment_reported";	

		}else if(t.com_s_type.value=="ip")

		{

			t.act.value="ip_comment_reported";	

		}else{

			t.act.value="icon_comment_reported";		

		}

		t.submit();

	

}

function preview_comment(a)

{

	var path=SVP;

	t=this.document.frm_comment;

	comment=encodeURI(t.com_comment.value);

	if(t.com_s_type.value=="profile")

	{

		path=SVP+"author_profile.php?act=profile_comment_preview&width=750&height=200&com_comment="+comment;

	}else if(t.com_s_type.value=="ip")

	{

		path=SVP+"ip.php?act=ip_comment_preview&width=750&height=200&com_comment="+comment;

	}else{

		path=SVP+"icon.php?act=icon_comment_preview&width=750&height=200&com_comment="+comment;

	}

	tb_show("<b>Loadzy</b>",path,"");

}



function captcha_refresh()

{

	document.getElementById("captcha_img").src =SVP+'captcha.php?' + Math.random();

}



function validateEmail(elementValue)

{  

	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  

	return emailPattern.test(elementValue);  

}  

function show_commuinity_nb(a)

{

	var nb_id="nb_"+a;

	var sort_id="sort_"+a;

	document.getElementById("nb_designer").style.display="none";

	document.getElementById("sort_designer").style.display="none";

	document.getElementById("nb_premium").style.display="none";

	document.getElementById("sort_premium").style.display="none";

	document.getElementById("nb_regular").style.display="none";

	document.getElementById("sort_regular").style.display="none";

	

	document.getElementById(nb_id).style.display="";

	document.getElementById(sort_id).style.display="";

}

function view_home_ip(a)

{

	var view_id="view_ip_"+a;

	document.getElementById("view_ip_latest").style.display="none";

	document.getElementById("view_ip_rated").style.display="none";

	document.getElementById("view_ip_downloaded").style.display="none";

	if(a!="")

	document.getElementById(view_id).style.display="";

}

function view_all_icon(a)

{

	var view_id="view_icon_"+a;

	document.getElementById("view_icon_random").style.display="none";

	document.getElementById("view_icon_latest").style.display="none";

	document.getElementById("view_icon_rated").style.display="none";

	document.getElementById("view_icon_downloaded").style.display="none";

	if(a!="")

	document.getElementById(view_id).style.display="";

}



function chk_submit_ip()

{

	t=this.document.frm_submit;

	if(t.ip_cat_id.value=="-1" || t.ip_title.value=="" || t.ip_author.value=="" || t.ip_lic_id.value=="-1" || (t.ip_lic_id.value=="1" && t.ip_license.value=="" ))

	{

		alert("Please fill all * marked fields to proceed.");

		return false;

	}

	if(t.ip_img_window.value=="" && t.ip_img_mac.value=="" && t.ip_img_linux.value=="")

	{

		alert("Please browse at least one icon pack archive to upload.");

		return false;

	}

	if(t.captcha.value=="")

	{

		alert("Please enter the confirmation code.");

		return false;

	}

	return true;

}

function show_other_licence()

{

	if(this.document.getElementById("ip_lic_id").value=="1")

	{

	  	this.document.getElementById("ip_other_license").style.display="";

		//this.document.getElementById("ip_license_img").style.display="";

	}else{

	    this.document.getElementById("ip_other_license").style.display="none";

		//this.document.getElementById("ip_license_img").style.display="none";	

	}

   	

}

function chk_contact()

{

	t=this.document.frm_contact;

	if(t.email.value=="" ||t.comment.value=="" || t.captcha.value=="")

	{

	  	alert("Please fill all * marked fields to proceed.");

		return false;

	}

	if(!validateEmail(t.email.value))

	{

		alert("Please enter your vaild email address");

		return false;

	}

	return true;

   	

}
