var color_pub	=	1;
var font_pub	=	1;
var path		=	'http://myepig.com/';
//var path		=	'http://abrar/myep/';

$(document).ready(function() {
				   
	$("#MyePig_Centered_clr li").mouseover(function() {
      var selected = $(this).attr('value');
	 $("#MyePig_Centered_clr_sel option[value='"+selected+"']").attr('selected', 'selected');
 	 $("#MyePig_Centered_img").attr("src", "http://myepig.com/template_imgs/"+ $("#MyePig_Centered_font_sel").val()+"/MyePig_Centered/"+selected+".jpg");
	 
	 color_pub	=	selected;
	 font_pub	=	$("#MyePig_Centered_font_sel").val();
 
});

//.............................
	$("#MyePig_Centered_font li").mouseover(function() {
      var selected = $(this).attr('value');
	 $("#MyePig_Centered_font_sel option[value='"+selected+"']").attr('selected', 'selected');
 	 $("#MyePig_Centered_img").attr("src", "http://myepig.com/template_imgs/"+selected+"/MyePig_Centered/"+ $("#MyePig_Centered_clr_sel").val()+".jpg");

		color_pub	=	$("#MyePig_Centered_clr_sel").val();
		font_pub	=	selected;
});
//.............................
});	

function update_templage(color_sel,font_sel,tmp_name,wb_rg)
	{
		
		var color	=	document.getElementById(color_sel).value ;
		var font	=	document.getElementById(font_sel).value ;
		var data = 'color=' + color +'&font='+font+'&tmp='+tmp_name+'&rg='+wb_rg;
		$.ajax({
			//this is the php file that processes the data and send mail
			url:  path +"website/update_template",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			window.location	=	path+'websites/edit/'+html;			
			}		
		});
		
	}
//.................................................
function prview(tmp_name)
	{
		 window.open(path+"websites/preview/"+color_pub+"/"+tmp_name+"/"+font_pub,'template_preview','location=no, menubar=no, status=no, toolbar=no, resizable=yes, width=660px, height=500px, top=0px, left=0px, scrollbars=yes');		
	}
//..............................................
function hideDiv(str) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(str).style.display = 'none'; 
document.getElementById('ytube_video_sr').innerHTML='';
}  
}
//..............................................
function showDiv(str) 
{ 
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6 
		document.getElementById(str).style.display = 'block'; 
	} 
} 
//.................................................
function checkWebSite(name)
	{
		var data = 'web_name=' + name;
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"website/checkWebsiteAvailability",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			if(html=="0")
				{
					document.getElementById('webNameAvail').innerHTML='Not Available';	
				}
			if(html=="2")
				{
					document.getElementById('webNameAvail').innerHTML='Invalid name';	
				}
			if(html=="1")
				{
					document.getElementById('webNameAvail').innerHTML='Available';	
				}
			}		
		});
	}
//.................................................
function checkRegistryName(name)
	{
		var data = 'web_name=' + name;
		$.ajax({
			//this is the php file that processes the data and send mail
			//url: "http://myepig.com/websites/checkWebsiteAvailability",	
			url: path+"website/checkWebsiteAvailability",	
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			if(html=="0")
				{
					document.getElementById('webRgistryAvail').innerHTML='Not Available';	
				}
			if(html=="2")
				{
					document.getElementById('webRgistryAvail').innerHTML='Invalid name';	
				}
			if(html=="1")
				{
					document.getElementById('webRgistryAvail').innerHTML='Available';	
				}
			}		
		});
	}

//.................................................
function show_ajax()
	{
		document.getElementById('ajax_show_progress').style.display='block';
		return false;
				
	}
//.................................................
function update_vision_title(id)
	{
		
		var title	=	document.getElementById(id).value ;
		var data = 'title=' + title;
		document.getElementById('errormsg52855').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"website/updatevisionboardtitle",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			if(html==1)
				{
					document.getElementById('vbtitle125555').innerHTML	=	title;	
					window.location	=	path+'myvisionboard/view';
				}
			else
				{
					document.getElementById('errormsg52855').innerHTML	=	html;
				}
			
			}		
		});
		
	}
//.................................................
function get_sub_cat(id)
	{
		
		var data = 'cat_id=' + id;
		document.getElementById('subcatid1111111').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"myvisionboard/getsubcategorylist",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			
			document.getElementById('subcatid1111111').innerHTML	=	html;
			}		
		});
		
	}
//.................................................
function get_sub_cat2(id)
	{
		
		var data = 'cat_id=' + id;
		document.getElementById('subcatid1111111').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"myvisionboard/getsubcategorylist2",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			
			document.getElementById('subcatid1111111').innerHTML	=	html;
			}		
		});
		
	}

//.................................................
function get_visionboards(subcatid)
	{
		
		var data = 'subcat_id=' + subcatid;
		document.getElementById('vision444455555555').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"myvisionboard/getvisionboards",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			var arr			=	eval(html);
			var html_page	=	String();
			var counter		=	1;
			html_page	='<div class="vision_board_images" >';
			for(i=0;i<arr.length;i++)
				{
					var name 	=	arr[i].vb_name;
					//alert(name);
					html_page	+='<div class="vb_bg" id="vb_main_dv2222'+arr[i].vb_id+'"><div id="vb_img_id123'+arr[i].vb_id+'" style="position:absolute; width:auto; height:auto; display:none;"><a id="vb_image_dyn222'+arr[i].vb_id+'" href="'+path+'vision_board_img/'+arr[i].vb_pic+'"><img src="'+path+'images/visionboard_hover.png" alt="" border="0" style="width:423px;height:264px;margin:8px 0 0 9px;" /></a></div><div class="vb_bg_pic"><a href="#"><img src="'+path+'vision_board_img/'+arr[i].vb_pic+'" alt="" border="0" style="width:423px;height:264px;"/></a></div><div class="nameof_visionboard" style="margin-top:1px;"><input name="vision_board_type" type="radio" value="'+arr[i].vb_name+'" />'+name +'</div></div>';
					if(counter/3==0)
						{
							html_page	+='</div><div class="vision_board_images" >';
						}
				}
			html_page	+='</div>';
			
			document.getElementById('vision444455555555').innerHTML	=	html_page;
			}		
		});
		
	}
//.................................................
function getVisionboardsByCat(catid)
	{
		
		var data = 'catid=' + catid;
		document.getElementById('vision444455555555').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"myvisionboard/getVisionboardsByCat",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			var arr			=	eval(html);
			var html_page	=	String();
			var counter		=	1;
			html_page	='<div class="vision_board_images" >';
			for(i=0;i<arr.length;i++)
				{
					var name 	=	arr[i].vb_name;
					//alert(name);
					html_page	+='<div class="vb_bg" id="vb_main_dv2222'+arr[i].vb_id+'"><div id="vb_img_id123'+arr[i].vb_id+'" style="position:absolute; width:auto; height:auto; display:none;"><a id="vb_image_dyn222'+arr[i].vb_id+'" href="'+path+'vision_board_img/'+arr[i].vb_pic+'"><img src="'+path+'images/visionboard_hover.png" alt="" border="0" style="width:423px;height:264px;margin:8px 0 0 9px;" /></a></div><div class="vb_bg_pic"><a href="#"><img src="'+path+'vision_board_img/'+arr[i].vb_pic+'" alt="" border="0" style="width:423px;height:264px;"/></a></div><div class="nameof_visionboard" style="margin-top:1px;"><input name="vision_board_type" type="radio" value="'+arr[i].vb_name+'" />'+name +'</div></div>';
					if(counter/3==0)
						{
							html_page	+='</div><div class="vision_board_images" >';
						}
						counter++;
				}
			html_page	+='</div>';
			document.getElementById('vision444455555555').innerHTML	=	html_page;
			get_sub_cat2(catid);
			}		
		});
		
	}
//.................................................
function focusOnElement() { 
$('#div_scroll_goto2222').goTo();
} 
//.................................................
function like_registry(registry,method22)
	{
		var data = 'registry='+registry+'&method22='+method22;
		document.getElementById('comment222222-'+registry).innerHTML	=	'<img src="'+path+'images/loader.gif" style="height:20px; width:20px; border:none; margin-top:-3px;" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"registry/add_like",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			document.getElementById('comment222222-'+registry).innerHTML	=	'';
			}		
		});

	}
//.................................................
function getCookie(c_name)
	{

		if (document.cookie.length>0)
		  {
			  c_start=document.cookie.indexOf(c_name + "=");
			  if (c_start!=-1)
				{
					c_start=c_start + c_name.length+1;
					c_end=document.cookie.indexOf(";",c_start);
					if (c_end==-1) c_end=document.cookie.length;
					return unescape(document.cookie.substring(c_start,c_end));
				}
		  }
		return "";
	}
//.......................................................................................
function set_cookie_for_vote(str,str1)
	{
		date = new Date();
		date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 30)); 
		document.cookie = str + "=" + str1 + "; expires=" + date.toGMTString(); 
	}
//.................................................
function getItemsByCat(catid)
	{
		
		var data = 'catid=' + catid;
		document.getElementById('vision444455555555').innerHTML	=	'<img src="'+path+'images/loader.gif" />';
		$.ajax({
			//this is the php file that processes the data and send mail
			url: path+"items/getItemsByCat",	
			
			//GET method is used
			type: "POST",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {
			//window.location	=	'http://myepig.com/websites/edit/'+html;
			var arr			=	eval(html);
			var html_page	=	String();
			var counter		=	1;
			//html_page	='<div class="addpremade_items">';
			for(i=0;i<arr.length;i++)
				{
					var name 	=	arr[i].itme_name;
					//alert(name);
					html_page	+='<div class="add_itemsimg"><div class="add_itemsimgpic"><img src="'+path+'itmes_images/thumbs/'+arr[i].itme_picture+'" alt="" width="80" height="60" border="0" /></div><div class="add_itemsform"><input name="chkbox'+arr[i].item_id+'" id="chkbox'+arr[i].item_id+'" type="checkbox" value="'+arr[i].item_id+'" /></div><div class="add_itemstxt">'+name+'</div></div>';
					if(counter/4==0)
						{
							//html_page	+='</div><div class="addpremade_items">';
						}
					counter++;
				}
			
			//alert(html_page);
			document.getElementById('vision444455555555').innerHTML	=	'';
			document.getElementById('htmlCat444455555555').innerHTML	=	html_page;
			}		
		});
		
	}
//.................................................
