var ajax_url="index.php?rt=ajax/result/";
var friend_request_image="http://www.moreondesign.com/views/images/connect_add.png";
var friend_request_image1="http://www.moreondesign.com/views/images/connect_add1.png";
var respond_friend_image="http://www.moreondesign.com/views/images/respond_friend.png";
var respond_friend_image1="http://www.moreondesign.com/views/images/respond_friend1.png";
var category_subscribe_image="http://www.moreondesign.com/views/images/SubscribeButton.png";
var category_subscribe_image1="http://www.moreondesign.com/views/images/SubscribeButtonO.png";


function imageSlider(a,b){
        document.getElementById('portfolio').style.display="none";
        document.getElementById('image').style.display="none";
        document.getElementById('video').style.display="none";
        
		document.getElementById('gallery_portfolio').className="none";
        document.getElementById('gallery_image').className="none";
        document.getElementById('gallery_video').className="none";
        
        document.getElementById(a).style.display="block";
        document.getElementById(b).className="active";
		document.getElementById("active").value=a;
		moredesign_ed(a);
		
        
}
function popup(url){
        window.open( url, "myWindow","status = 1, height = 400, width = 780,");
}
function next_page(){
	if($("#active").val()=="portfolio"){
		if(parseInt($("#portfolio_pages").val()) > parseInt($("#portfolio_page").val())){
			$("#portfolio_page").val(parseInt($("#portfolio_page").val())+1);
			moredesign_ed("portfolio");
			get_page($("#active").val(),$("#portfolio_page").val(),"#portfolio");
		}
	}
	if($("#active").val()=="image"){
		if(parseInt($("#image_pages").val()) > parseInt($("#image_page").val())){
			$("#image_page").val(parseInt($("#image_page").val())+1);
			moredesign_ed("image");
			get_page($("#active").val(),$("#image_page").val(),"#image");
		}
	}
	if($("#active").val()=="video"){
		if(parseInt($("#video_pages").val()) > parseInt($("#video_page").val())){
			$("#video_page").val(parseInt($("#video_page").val())+1);
			moredesign_ed("video");
			get_page($("#active").val(),$("#video_page").val(),"#video");
		}
	}
}
function prev_page(){
	if($("#active").val()=="portfolio"){
		if(parseInt($("#portfolio_page").val())>1){
			$("#portfolio_page").val(parseInt($("#portfolio_page").val())-1);
			moredesign_ed("portfolio");
			get_page($("#active").val(),$("#portfolio_page").val(),"#portfolio");
		}
	}
	if($("#active").val()=="image"){
		if(parseInt($("#image_page").val())>1){
			$("#image_page").val(parseInt($("#image_page").val())-1);
			moredesign_ed("image");
			get_page($("#active").val(),$("#image_page").val(),"#image");
		}
	}
	if($("#active").val()=="video"){
		if(parseInt($("#video_page").val())>1){
			$("#video_page").val(parseInt($("#video_page").val())-1);
			moredesign_ed("video");
			get_page($("#active").val(),$("#video_page").val(),"#video");
		}
	}
}
function moredesign_ed(active){
	if(active=="portfolio"){
		if(parseInt($("#portfolio_pages").val()) > parseInt($("#portfolio_page").val())){
			$("#nextpage").html("<a  href='javascript://' onclick='next_page()'><img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' /></a>");
		}else{
			$("#nextpage").html("<img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' />");
		}

		if(parseInt($("#portfolio_page").val())>1){
			$('#prevpage').html("<a href='javascript://' onclick='prev_page()'><img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' /></a>");
		}else{
			$('#prevpage').html("<img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' />");
		}
	}
	if(active=="image"){
		if(parseInt($("#image_pages").val()) > parseInt($("#image_page").val())){
			$("#nextpage").html("<a  href='javascript://' onclick='next_page()'><img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' /></a>");
		}else{
			$("#nextpage").html("<img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' />");
		}
		if(parseInt($("#image_page").val())>1){
			$('#prevpage').html("<a href='javascript://' onclick='prev_page()'><img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' /></a>");
		}else{
			$('#prevpage').html("<img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' />");
		}
	}
	if(active=="video"){
		if(parseInt($("#video_pages").val()) > parseInt($("#video_page").val())){
			$("#nextpage").html("<a  href='javascript://' onclick='next_page()'><img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' /></a>");
		}else{
			$("#nextpage").html("<img src='http://www.moreondesign.com/views/images/right-Arrow.png' alt='' />");
		}
		if(parseInt($("#video_page").val())>1){
			$('#prevpage').html("<a href='javascript://' onclick='prev_page()'><img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' /></a>");
		}else{
			$('#prevpage').html("<img src='http://www.moreondesign.com/views/images/Left-Arrow.png' alt='' />");
		}
	}
}
function save_post(id,did){
	$.ajax({
		type: "POST",
		url: ajax_url ,
		data: "act=post_save&post_id=" + id,
		success: function(msg){
			if(msg=="2"){
				location.href="http://www.moreondesign.com/post/save_post/" + id + "/";
			}else{
				$(did).hide();
				$("#saved_info").show();
				
			}
		}
	});		
}

function get_page(active,page,id){
	$.ajax({
		type: "POST",
		url: ajax_url ,
		data: "active=" + active + "&page=" + page,
		success: function(msg){
			$(id).html(msg);
		}
	});		
}

function toggle_fun(did){
	var name='#'+did;
	jQuery(document).ready(function(){
	jQuery(name).toggle("slow");
	});
}



function PostAjax(Aurl){
	$.ajax({
	type: "POST",
	url: Aurl,
	data: "add_category=" + $("#add_category").val(),
	success: function(msg){
		var obj = $.evalJSON(msg); 
		if(obj.status == 'insert'){
			$("#add_category").val("");
			
			
			
		}
	}
	});
}

function add_new_tag(value){
	$('#add_category').val(value);
	$('#add_tag').click();

}

function hide_show(){

	
	


}

function call_recent(){
	$("#topic_category").click();
}

function add_tags(t){
	var tags=jQuery("#tags").val();
	var temp=tags.split(",");
	if(jQuery.inArray(t, temp)<0){
		if(tags==""){
			tags=t;
		}else{
			tags=tags + "," + t;
		}
		jQuery("#tags").val(tags);
	}
}


function rate_topic(v){
	$("#topic_rate").val(v);
	document.frmmsg.submit();
}

function show_portfolio(id){
	$("#post_id").val(id);
	//$("#pshow").val(1);
	$("#search").submit();
}

$(document).ready(function(){
	$("#select_all").click(function(){
		var checked_status = this.checked;
		$("input[@class=checkbox]").each(function(){
			this.checked = checked_status;
		});
	});

	$("#select_all1").click(function(){
		var checked_status = this.checked;
		$("input[@class=checkbox]").each(function(){
			this.checked = checked_status;
		});
	});
	//Tool tip
	$("a").tooltip();
	$("input").tooltip();
	$("select").tooltip();
	$("textarea").tooltip();
	//end

	// Drop Down Menu (multi level)
	$("#menu ul li").hover(function(){
	$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(268); 
	},function(){
	$(this).find('ul:first').css({visibility: "hidden"});
	});
	// End of Menu
//Right Panel

$("#gsearch").click(function(){
	if(this.checked){
			$("#googlesearch").show();
			$("#mysearch").hide();
			
	}
});

$("#publish").mouseover(function(){
	$("#publish_tip").show();
});
$("#publish").mouseout(function(){
	$("#publish_tip").hide();
});

$("#connect").mouseover(function(){
	$("#connect_tip").show();
});
$("#connect").mouseout(function(){
	$("#connect_tip").hide();
});

$("#msearch").click(function(){
	if(this.checked){
			$("#googlesearch").hide();
			$("#mysearch").show();
			
	}
});


$("#custom_search").click(function(){
	if($("#custom_search").val()=="Custom Search"){
		$("#custom_search").val("");
	}
});
$("#custom_search").blur(function(){
	if($("#custom_search").val()==""){
		$("#custom_search").val("Custom Search");
	}
});




	

	$("#add_myfavorite").click(function(){
		$.ajax({ 
			type: "POST",
			url: ajax_url ,
			data: "favorit_type=" + $("#favorite_type").val() + "&my_favorite=" + $("#my_favorite").val(),
			success: function(msg){

			}
		});	
	});


	$("#topic_category").click(function(){
		$("#popular_topic_content").html("<div style='text-align:center;vertical-align:middle'>Loading...</div>");
		$.ajax({
			type: "POST",
			url: ajax_url ,
			data: "post_type=category",
			success: function(msg){
				$("#popular_topic_content").html(msg);
				$("#topic_category").attr("class","active");
				$("#topic_recent").attr("class","");
				$("#topic_most_viwed").attr("class","");
			}
		});	
	});

	$("#topic_recent").click(function(){
		$("#popular_topic_content").html("<div style='text-align:center;vertical-align:middle'>Loading...</div>");
		$.ajax({
			type: "POST",
			url: ajax_url ,
			data: "post_type=recent_post",
			success: function(msg){
				$("#popular_topic_content").html(msg);
				$("#topic_category").attr("class","");
				$("#topic_recent").attr("class","active");
				$("#topic_most_viwed").attr("class","");
			}
		});	
	});

	
	$("#topic_most_viwed").click(function(){
		$("#popular_topic_content").html("<div style='text-align:center;vertical-align:middle'>Loading...</div>");
		$.ajax({
			type: "POST",
			url: ajax_url ,
			data: "post_type=most_view",
			success: function(msg){
				$("#popular_topic_content").html(msg);
				$("#topic_category").attr("class","");
				$("#topic_most_viwed").attr("class","active");
				$("#topic_recent").attr("class","");
			}
		});
	});

	

			

//End Right Panel
//home

	$("#latest_press_releases").click(function(){
			$("#latest_type").val("press-release");
			document.latestfrm.submit();
	});
	$("#latest_company_news").click(function(){
			$("#latest_type").val("company-news");
			document.latestfrm.submit();
	});
	$("#latest_article").click(function(){
			$("#latest_type").val("article");
			document.latestfrm.submit();
	});



//home
//Comment
	
	$("#expand_comment").click(function(){
		$("#comment_list").toggle("slow");
		if($("#expand_comment").html()=="show"){
			$("#expand_comment").html("hide");
			$("#show").show();
		}else{
			$("#expand_comment").html("show");
			$("#show").hide();
		}
	});

//Post Add Page
	$("#show_tags").click(function(){
			$("#old_tags").show();
	});

	$("#add_more_image").click(function(){
		var cnt=parseInt($("#total_image").val());
		if(cnt<8){
			$("#add_more").append("<div style='padding-top:10px'><input type='text' name='post[img_alt][]' title='Please enter image alt text' class='inputText'   size='36' style='width:49%'>&nbsp;<input type='file' name='post[image][]' class='inputFile inputText'  size='24' style='width:49%'></div>");
			cnt=parseInt(cnt+1);
			$("#total_image").val(cnt)
		}
	});


	$("#add_more_compimage").click(function(){
		var cnt=parseInt($("#total_compimage").val());
		if(cnt<3){
			$("#add_compmore").append("<div style='padding-top:10px'><input type='text' title='Please enter image alt text' name='post[comp_alt][]' class='inputText'  size='36' style='width:49%'>&nbsp;<input type='file' name='post[comp_image][]' class='inputFile inputText'  size='24' style='width:49%'></div>");
			cnt=parseInt(cnt+1);
			$("#total_compimage").val(cnt)
		}
	});

	

	$("#add_more_image_event").click(function(){
		var cnt=parseInt($("#total_image").val());
		if(cnt<3){
			$("#add_more").append("<div style='padding-top:10px'><input type='text' name='event[img_alt][]' title='Please enter image alt text' class='inputText'   size='36' style='width:49%'>&nbsp;<input type='file' name='event[image][]' class='inputFile inputText'  size='24' style='width:49%'></div>");
			cnt=parseInt(cnt+1);
			$("#total_image").val(cnt)
		}
	});

	$("#add_more_portfolio").click(function(){
		var cnt=parseInt($("#total_image").val());
		if(cnt<8){
			$("#add_more").append("<div style='padding-top:10px'><input  type='text' name='portfolio[img_alt][]' class='inputText' title='Please enter image alt text'  size='36' style='width:48%'>&nbsp;<input type='file' name='portfolio[image][]' class='inputFile inputText'  size='24' style='width:49%'></div>");
			cnt=parseInt(cnt+1);
			$("#total_image").val(cnt)
		}else{
			$("#add_more_portfolio").hide();
		}
	});
	

	$("#post_type").change(function(){
		if($("#post_type").val()=="article" || $("#post_type").val()=="latest-news" || $("#post_type").val()=="competitions" || $("#post_type").val()=="interviews" || $("#post_type").val()=="case-studies" || $("#post_type").val()=="videos" || $("#post_type").val()=="colleges" || $("#post_type").val()=="books"){
			$("#company_detail").hide();
			$("#article").show();
		}else{
			$("#company_detail").show();
			$("#article").hide();
		}
		if($("#post_type").val()=="directory-listing"){
			$("#post_detail").hide();
			$("#company_list").hide();
			$("#company_id").val("");
			$("#comp_para").show();
			$("#product_para").hide();
			
		}else{
			$("#post_detail").show();
			$("#company_list").show();
			$("#comp_para").hide();
			$("#product_para").show();
		}

		if($("#post_type").val()=="books"){
			$("#books_url").show();
		}else{
			$("#books_url").hide();
		}
		
		
	});


	$("#company_id").change(function(){
		$.ajax({
		type: "POST",
		url: ajax_url ,
		data: "company_id=" + $("#company_id").val(),
		success: function(msg){
			var obj = $.evalJSON(msg);
			if($("#company_id").val()!=""){
				$("#company").val(obj.company);
				$("#contact_person").val(obj.contact_person);
				$("#contact_designation").val(obj.contact_designation);
				$("#address").val(obj.address);
				$("#city").val(obj.city);
				$("#state").val(obj.state);
				$("#zip_code").val(obj.zip_code);
				$("#email").val(obj.email);
				$("#country").val(obj.country);
				$("#website").val(obj.website);
				$("#organization_type").val(obj.organization_type);
				$("#coverage_area").val(obj.coverage_area);
				$("#profile").val(obj.profile);
			}else{
				$("#company").val("");
				$("#contact_person").val("");
				$("#contact_designation").val("");
				$("#address").val("");
				$("#city").val("");
				$("#state").val("");
				$("#zip_code").val("");
				$("#email").val("");
				$("#country").val("");
				$("#website").val("");
				$("#organization_type").val("");
				$("#coverage_area").val("");
				$("#profile").val("");
			}
		}
		});		
	});
//End post add page


//Homepage 
	$("#a_update").click(function(){
		$("#a_update").attr("class","active");
		$("#update_api").show();

		$("#a_stock").attr("class","");
		$("#a_conversion").attr("class","");
		$("#stocks_api").hide();
		$("#conversion_api").hide();
	});

	$("#a_stock").click(function(){
		$("#a_stock").attr("class","active");
		$("#stocks_api").show();

		$("#a_update").attr("class","");
		$("#a_conversion").attr("class","");
		$("#update_api").hide();
		$("#conversion_api").hide();
	});
	
	$("#a_conversion").click(function(){
		$("#a_conversion").attr("class","active");
		$("#conversion_api").show();

		$("#a_update").attr("class","");
		$("#a_stock").attr("class","");
		$("#update_api").hide();
		$("#stocks_api").hide();
	});
//	End Home page
	$("#rate1").click(function(){
		rate_topic(2);		
	});
	$("#rate2").click(function(){
		rate_topic(4);		
	});
	$("#rate3").click(function(){
		rate_topic(6);		
	});
	$("#rate4").click(function(){
		rate_topic(8);		
	});
	$("#rate5").click(function(){
		rate_topic(10);		
	});

	//Friend Request Image
	$("#friend_request_add").mouseover(function(){
		$("#friend_request_add").attr("src",friend_request_image1);
	});
	$("#friend_request_add").mouseout(function(){
		$("#friend_request_add").attr("src",friend_request_image);
	});

	$("#respond_friend").mouseover(function(){
		$("#respond_friend").attr("src",respond_friend_image1);
	});
	$("#respond_friend").mouseout(function(){
		$("#respond_friend").attr("src",respond_friend_image);
	});

	$("#category_subscribe_button").mouseover(function(){
		$("#category_subscribe_button").attr("src",category_subscribe_image1);
	});
	$("#category_subscribe_button").mouseout(function(){
		$("#category_subscribe_button").attr("src",category_subscribe_image);
	});

	$("#portfolio").click(function(){
		if($("#portfolio_content").attr("class")=="hide"){
			$("#portfolio_content").attr("class","show");
			$("#up_arrow_portfolio").attr("class","show rgt");
			$("#down_arrow_portfolio").attr("class","hide rgt");
		}else{
			$("#portfolio_content").attr("class","hide");
			$("#up_arrow_portfolio").attr("class","hide rgt");
			$("#down_arrow_portfolio").attr("class","show rgt");
		}
	});

	$("#profile").click(function(){
		if($("#profile_content").attr("class")=="hide"){
			$("#profile_content").attr("class","show");
			$("#up_arrow_profile").attr("class","show rgt");
			$("#down_arrow_profile").attr("class","hide rgt");
		}else{
			$("#profile_content").attr("class","hide");
			$("#up_arrow_profile").attr("class","hide rgt");
			$("#down_arrow_profile").attr("class","show rgt");
		}
	});

	

	$("#my_connections").click(function(){
		if($("#my_connections_content").attr("class")=="hide"){
			$("#my_connections_content").attr("class","show");
			$("#up_arrow_connections").attr("class","show rgt");
			$("#down_arrow_connections").attr("class","hide rgt");
		}else{
			$("#my_connections_content").attr("class","hide");
			$("#up_arrow_connections").attr("class","hide rgt");
			$("#down_arrow_connections").attr("class","show rgt");
		}
	});
	$("#my_job").click(function(){
		if($("#my_job_content").attr("class")=="hide"){
			$("#my_job_content").attr("class","show");
			$("#up_arrow_job").attr("class","show rgt");
			$("#down_arrow_job").attr("class","hide rgt");
		}else{
			$("#my_job_content").attr("class","hide");
			$("#up_arrow_job").attr("class","hide rgt");
			$("#down_arrow_job").attr("class","show rgt");
		}
	});

	$("#my_posting").click(function(){
		if($("#my_posting_content").attr("class")=="hide"){
			$("#my_posting_content").attr("class","show");
			$("#up_arrow_posting").attr("class","show rgt");
			$("#down_arrow_posting").attr("class","hide rgt");
		}else{
			$("#my_posting_content").attr("class","hide");
			$("#up_arrow_posting").attr("class","hide rgt");
			$("#down_arrow_posting").attr("class","show rgt");
		}
	});

	$("#my_favorites").click(function(){
		if($("#my_favorites_content").attr("class")=="hide"){
			$("#my_favorites_content").attr("class","show");
			$("#up_arrow_favorites").attr("class","show rgt");
			$("#down_arrow_favorites").attr("class","hide rgt");
		}else{
			$("#my_favorites_content").attr("class","hide");
			$("#up_arrow_favorites").attr("class","hide rgt");
			$("#down_arrow_favorites").attr("class","show rgt");
		}
	});
	$("#comments").click(function(){
		if($("#comment_list").attr("class")=="hide"){
			$("#comment_list").attr("class","show");
			$("#receive_comment").attr("class","hide");
			$("#comment_show").attr("class","show");
			//$("#expand_comment1").html("Hide");
			$("#up_arrow_comments").attr("class","show rgt");
			$("#down_arrow_comments").attr("class","hide rgt");
		}else{
			$("#comment_list").attr("class","hide");
			$("#receive_comment").attr("class","show");
			$("#comment_show").attr("class","hide");
			//$("#expand_comment1").html("Show");
			$("#up_arrow_comments").attr("class","hide rgt");
			$("#down_arrow_comments").attr("class","show rgt");
		}
	});



	

	$("#subscribe_category").click(function(){
		if($("#subscribe_category_content").attr("class")=="hide"){
			$("#subscribe_category_content").attr("class","show");
		}else{
			$("#subscribe_category_content").attr("class","hide");
		}
	});

	
	

	$("#project_location0").click(function(){
		$("#project_country").attr("class","hide");
	});
	$("#project_location1").click(function(){
		$("#project_country").attr("class","show");
	});

	$("#search").submit(function(){
		$("#pshow").val(1);
	});
	

	$("#category_id").change(function(){
		if($("#category_id").val()=="Other"){
			$("#other_category").attr("class","show");
		}else{
			$("#other_category").attr("class","hide");
		}
	});

	$("#portfolioimage").click(function(){
		$("#portfolio_image").attr("class","show");
		$("#portfolio_video").attr("class","hide");
	});

	$("#portfoliovideo").click(function(){
		$("#portfolio_video").attr("class","show");
		$("#portfolio_image").attr("class","hide");
	});

	$("#save_post").click(function(){
		save_post($("#save_post").val(),"#save_info");
	});
	$("#saved_post").click(function(){
		$("#saved_post").attr("checked",true);
	});


	$("#cat_what").click(function(){
			$("#what_content").attr("class","show");
			$("#who_content").attr("class","hide");
			$("#cat_what").attr("class","whiteBG");
			$("#cat_who").attr("class","");
	});
	$("#cat_who").click(function(){
			$("#what_content").attr("class","hide");
			$("#who_content").attr("class","show");
			$("#cat_who").attr("class","whiteBG");
			$("#cat_what").attr("class","");
	});

});

