$(document).ready(function(){
	$(".somedet").hide('fast');
	$("#rules").hide('fast');
	$("#bigpic").hide('fast');
	$("#results").hide('fast');
	$("#mainpiccer").load('piclist.php');
	$("#rules").click();
	hideRule();
	$("body").keypress(function(e){
       if(e.keyCode=="13"){
			Searchit();
       }
    });
});

function freeTunes(){
	window.open('http://savemart.pocmedia.com/musicdown/?s=smart','','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
	
}

function Searchit(){
	var q = $("#searchq").val();
	if(q.length>1){
		$.post('searchum.php',{q: q}, function(data) {
			$('#results').html(data);
			$(".picrowtit").hide('medium');
			$("#bigpic").hide('medium');
			$("#userbuts").hide('medium');
			$('#results').show('medium');
		});
	}
}

function seeAll(){
		$.post('searchum.php',{all: "true"}, function(data) {
			$('#results').html(data);
			$(".picrowtit").hide('medium');
			$("#bigpic").hide('medium');
			$("#userbuts").hide('medium');
			$('#results').show('medium');
		});
}

function delPic(acode){
	var answer = confirm("Are you sure you want to delet this picture? This cannot be undone!")
	if (answer){
		var answerb = confirm("Are Absolutely Sure? All Previose Votes for this pic will be removed from our system!")
		if (answerb){
			$.post('delpic.php',{code: acode});
			closPic();
	}
	}
}

function chTit(acode,anid){
	var newnam = prompt("Please enter a New Title", "")
	if(newnam.length>0){
		$.post('chtit.php',{code: acode, ntit: newnam}, function(data) {
			$("#feedback").html(data);
			if(data == "already"){
				$("#feedback").html('You Already have a Picture With that Title');
			} else if(data == "tooshort"){
				$("#feedback").html('Your Title must conatin at least 2 letters');
			} else if(data == "good"){
				myPics(anid);
			}
		});
	
	}	
	
}
function showRule(){
	$("#uploader").hide('medium');
	$("#results").hide('medium');
	$("#bigpic").hide('medium');
	$("#userbuts").hide('medium');
	$("#mainpiccer").hide('medium');
	$("#rules").show('medium');
		
}
function goPic(ath,sq){
	var anid = ath.id;
	$.post('seepic.php',{p: anid, s: sq}, function(data) {
		$('#bigpic').html(data);
	});
	$("#bigpic").show('medium');
	$(".picrowtit").hide('medium');
	$("#results").hide('medium');
	$("#userbuts").hide('medium');	
}

function vOte(id,tit){
	$.post('addvot.php',{id: id, tit: tit}, function(data) {
		if(data=="1"){
			$('#votecount').html(data+" Vote");
		} else {
			$('#votecount').html(data+" Votes");
		}
		$('#vbuth').html("<div class='voted' title='You Can Only Vote Once A Day'>Thanks For Voting</div>");
	});
}
function myPics(anid){
	$.post('searchum.php',{q: anid, s: "true"}, function(data) {
			$('#results').html(data);
			$(".picrowtit").hide('medium');
			$("#bigpic").hide('medium');
			$("#userbuts").hide('medium');
			$('#results').show('medium');
		});
}

function closPic(){
	$("#mainpiccer").load('piclist.php');
	$("#bigpic").hide('medium');
	$("#results").hide('medium');
	$(".picrowtit").show('medium');
	$("#userbuts").show('medium');
}

function b2search(){
	$("#bigpic").hide('medium');
	$("#results").show('medium');
}

function hideRule(){
	$("#rules").hide('medium');
	$("#uploader").hide('medium');
	$("#userbuts").show('medium');
	$(".picrowtit").show('medium');
	$("#mainpiccer").show('medium');	
}

function dodadang(adiv,anam){
	$("#featpart").hide('medium');
	$("#"+adiv.id+"-det").show('medium');
	$("#"+adiv.id+"-wall").html("<iframe src='face?l="+anam+"' allowTransparency='true' width='100%' height='100%' border='0'></iframe>");
}

function picUpper(){
	$("#rules").hide('medium');
	$("#bigpic").hide('medium');
	$("#results").hide('medium');
	$("#mainpiccer").hide('medium');
	$("#uploader").html("<iframe src='picup' scrolling='no' allowTransparency='true' width='100%' height='100%' border='0'></iframe>");	
	$("#uploader").show('medium');
}

function btoall(adiv){
	$("#"+adiv).hide('medium');
	$("#featpart").show('medium');
}

function helpUs() {

   var UniqueID = 314 // Make each link open in a new window
   //var newWinOffset = 0 // Position of first pop-up 
   

    PlayWin = window.open('',"onmcdetail",'width=545,height=465,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus();

    var winContent = "<HTML><HEAD><TITLE>Contact Us</TITLE></HEAD><BODY style='font-family:arial; background-image:url(images/featback.jpg);'>";
    winContent += "We hope to provide you with the best online experience possible, so we like to be available in case you need any assistance. If you have any trouble with this site (Save Mart/Lucky site) please feel free to contact us by either phone or email. <br><br>You can contact:<br> POC Media<br>Phone: 610-971-0416 <br> e-mail: <a href='mailto:andrewwebadmin@pocmedia.com'>andrewwebadmin@pocmedia.com</a><br><br>If you run into any trouble with the Official NASCAR Members Club site, you can contact the ONMC help desk: <br> By Phone: 1-877-MY-NASCAR <br> By Email: <a href='mailto:memberservice@onmc247.com'>memberservice@onmc247.com</a>";
    winContent += "</BODY></HTML>";

    PlayWin.document.write(winContent);
    PlayWin.document.close(); // "Finalizes" new window
    }

function printRule(){
	var incode = $(".darules").html();
	var UniqueID = 320
	PlayWin = window.open('',"onmcdetail",'width=545,height=465,resizable=0,scrollbars=1,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.document.write("<html><head><title>Contest Rules</title></head><body onload='window.print();'>"+incode+"</body></html>");
    PlayWin.document.close(); // "Finalizes" new window
}



function detOpen() {

   var UniqueID = 314 // Make each link open in a new window
   //var newWinOffset = 0 // Position of first pop-up 
   

    PlayWin = window.open('',"onmcdetail",'width=545,height=465,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus();

    var winContent = "<HTML><HEAD><TITLE>ONMC Benefits</TITLE></HEAD><BODY style='font-family:arial; background-image:url(images/featback.jpg);'>";
    winContent += "All Official NASCAR Members Club Members receive access to a Members-Only website that provides more details about the program and its unique opportunities, including:<div id='onmclist'><ul><li>Thousands of Local and National Shopping, Dining, Movie and Attraction discounts<li>Members-Only race weekend VIP treatment & experiences<li>Official Online Member Magazine<li>Thousands of Local Chapters & Headquarters across the country to bring NASCAR to your hometown<li>Enjoy local race-watch parties and Local Chapter events with Members who share your passion for NASCAR<li>Members-Only website featuring customized NASCAR news, events schedule, Local Chapter activities, Pre and Post-race news about your favorite driver, chats and discussion forums<li>Weekly club E-newsletter<li>10% OFF all purchases at NASCAR.com above and beyond all existing discounts<li>Exclusive Race Ticket offers and travel packages<li>Access to purchase exclusive Member Gear, limited edition merchandise and collectibles<li>NASCAR Celebrity Q&A sessions</ul>";
    winContent += "</BODY></HTML>";

    PlayWin.document.write(winContent);
    PlayWin.document.close(); // "Finalizes" new window
    }
    
    
    function lucky_detOpen() {

   var UniqueID = 316 // Make each link open in a new window
   //var newWinOffset = 0 // Position of first pop-up 
   

    PlayWin = window.open('',"onmcdetail",'width=545,height=550,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus();

      var winContent = "<HTML><HEAD><TITLE>ONMC Benefits</TITLE></HEAD><BODY style='font-family:arial; background-image:url(images/featback.jpg);'>";
    winContent += "Save Mart Supermarkets The Community Connection<br><br>For many NASCAR fans attending this year's Toyota/Save Mart 350, the name Save Mart has become synonymous with an event that has become better and better  with each of the 19 years that Save Mart has been associated with NASCAR and Infineon Raceway. Our customers have known for the last 59 years that Save Mart's association with an event is a virtual guarantee of success.<br><br>Save Mart is dedicated to improving the quality of life for our customers by being an active part of the community in every city that Save Mart proudly calls home. Save Mart touches the lives of our customers in many ways, from sponsoring youth athletic teams, making donations to a host of charitable organizations through the Save Mart S.H.A.R.E.S. card and participating in local community events too numerous to mention.<br><br>It is Save Mart's hope to positively affect our customers as they go about their daily lives. From Bakersfield to Chico and San Jose to Reno, Save Mart is there to provide communities with much-needed support for family-oriented activities and community building events. The Save Mart commitment to community goes even deeper than that of a business making a few donations to fulfill some sense of obligation. Our sense of duty is also to be found in many Save Mart employees, who spend countless hours of their spare time volunteering in their hometowns for their children's leisure activities and causes that they hold dear. That's what community is all about. Community is what Save Mart is all about. Save Mart and the family of Save Mart employees are connected to the community in way that has made Save Mart's  the favorite hometown grocer.";
    winContent += "</BODY></HTML>";

    PlayWin.document.write(winContent);
    PlayWin.document.close(); // "Finalizes" new window
    }
    
    
    function smart_detOpen() {

   var UniqueID = 318 // Make each link open in a new window
   //var newWinOffset = 0 // Position of first pop-up 
   

    PlayWin = window.open('',"onmcdetail",'width=545,height=550,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus();

    var winContent = "<HTML><HEAD><TITLE>ONMC Benefits</TITLE></HEAD><BODY style='font-family:arial; background-image:url(images/featback.jpg);'>";
   winContent += "Save Mart Supermarkets The Community Connection<br><br>For many NASCAR fans attending this year's Toyota/Save Mart 350, the name Save Mart has become synonymous with an event that has become better and better  with each of the 19 years that Save Mart has been associated with NASCAR and Infineon Raceway. Our customers have known for the last 59 years that Save Mart's association with an event is a virtual guarantee of success.<br><br>Save Mart is dedicated to improving the quality of life for our customers by being an active part of the community in every city that Save Mart proudly calls home. Save Mart touches the lives of our customers in many ways, from sponsoring youth athletic teams, making donations to a host of charitable organizations through the Save Mart S.H.A.R.E.S. card and participating in local community events too numerous to mention.<br><br>It is Save Mart's hope to positively affect our customers as they go about their daily lives. From Bakersfield to Chico and San Jose to Reno, Save Mart is there to provide communities with much-needed support for family-oriented activities and community building events. The Save Mart commitment to community goes even deeper than that of a business making a few donations to fulfill some sense of obligation. Our sense of duty is also to be found in many Save Mart employees, who spend countless hours of their spare time volunteering in their hometowns for their children's leisure activities and causes that they hold dear. That's what community is all about. Community is what Save Mart is all about. Save Mart and the family of Save Mart employees are connected to the community in way that has made Save Mart's  the favorite hometown grocer.";
    winContent += "</BODY></HTML>";

    PlayWin.document.write(winContent);
    PlayWin.document.close(); // "Finalizes" new window
    }

